From patchwork Thu Nov 7 13:51:43 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Brodkin X-Patchwork-Id: 289346 X-Patchwork-Delegate: hs@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 215902C0086 for ; Fri, 8 Nov 2013 01:00:40 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id BF4634A38A; Thu, 7 Nov 2013 15:00:30 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0U4bvEOxzjiX; Thu, 7 Nov 2013 15:00:30 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 15FA04A3AA; Thu, 7 Nov 2013 15:00:13 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 3C80E4A34B for ; Thu, 7 Nov 2013 14:59:55 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id z7rdB9xFjsgZ for ; Thu, 7 Nov 2013 14:59:49 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from kiruna.synopsys.com (us01smtp2.synopsys.com [198.182.44.80]) by theia.denx.de (Postfix) with ESMTP id 645A84A34D for ; Thu, 7 Nov 2013 14:59:38 +0100 (CET) Received: from WBSNus01mta1 (us01secmta1.synopsys.com [10.9.203.100]) by kiruna.synopsys.com (Postfix) with ESMTP id 9D822F2A4; Thu, 7 Nov 2013 05:51:59 -0800 (PST) Received: from us01secmta1.internal.synopsys.com (us01secmta1.internal.synopsys.com [127.0.0.1]) by us01secmta1.internal.synopsys.com (Service) with ESMTP id 8A6AC27113; Thu, 7 Nov 2013 05:51:59 -0800 (PST) Received: from mailhost.synopsys.com (mailhost2.synopsys.com [10.9.202.240]) by us01secmta1.internal.synopsys.com (Service) with ESMTP id 5CADC27102; Thu, 7 Nov 2013 05:51:59 -0800 (PST) Received: from mailhost.synopsys.com (localhost [127.0.0.1]) by mailhost.synopsys.com (Postfix) with ESMTP id 4D9A671F; Thu, 7 Nov 2013 05:51:59 -0800 (PST) Received: from abrodkin-8560l.internal.synopsys.com (abrodkin-8560l.internal.synopsys.com [10.121.8.102]) by mailhost.synopsys.com (Postfix) with ESMTP id 7742D6FF; Thu, 7 Nov 2013 05:51:54 -0800 (PST) From: Alexey Brodkin To: u-boot@lists.denx.de Date: Thu, 7 Nov 2013 17:51:43 +0400 Message-Id: <1383832303-11856-1-git-send-email-abrodkin@synopsys.com> X-Mailer: git-send-email 1.8.4.2 Cc: Alexey Brodkin , Peter Tyser , Stefan Roese , Mischa Jonker Subject: [U-Boot] [PATCH] cmd_eeprom: fix i2c_{read|write} usage if env is in I2C EEPROM X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Data "offset" is not used directly in case of I2C EEPROM. Istead it is split into "block number" and "offset within mentioned block". Which are "addr[0]" and "addr[1]" respectively. Signed-off-by: Alexey Brodkin Cc: Jean-Christophe PLAGNIOL-VILLARD cc: Peter Tyser Cc: Heiko Schocher Cc: Wolfgang Denk Cc: Stefan Roese Cc: Mischa Jonker --- common/cmd_eeprom.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/cmd_eeprom.c b/common/cmd_eeprom.c index ef694d8..02539c4 100644 --- a/common/cmd_eeprom.c +++ b/common/cmd_eeprom.c @@ -161,7 +161,7 @@ int eeprom_read (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt #if defined(CONFIG_SPI) && !defined(CONFIG_ENV_EEPROM_IS_ON_I2C) spi_read (addr, alen, buffer, len); #else - if (i2c_read (addr[0], offset, alen-1, buffer, len) != 0) + if (i2c_read (addr[0], addr[1], alen-1, buffer, len) != 0) rcode = 1; #endif buffer += len; @@ -339,7 +339,7 @@ int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cn /* Write is enabled ... now write eeprom value. */ #endif - if (i2c_write (addr[0], offset, alen-1, buffer, len) != 0) + if (i2c_write (addr[0], addr[1], alen-1, buffer, len) != 0) rcode = 1; #endif