On Thu, 2013-11-28 at 10:47 +0800, Kuo-Jung Su wrote: > From: Kuo-Jung Su <dant...@faraday-tech.com> > > The local pointer of address (i.e., addr) only gets > referenced in SPI mode, and it won't be appropriate > to pass only 1 bytes addr[1] to i2c_read/i2c_write while > CONFIG_SYS_I2C_EEPROM_ADDR_LEN > 1. > > To avoid ambiguity, this patch would drop the use of > address pointer in I2C mode, and directly pass (dev_addr, offset) > to i2c_read/i2c_write.
Unfortunately this patch breaks cases with "CONFIG_SYS_I2C_EEPROM_ADDR_LEN = 1" where address is limited to 1 byte - thus a need to pass "addr[0]" which is combined from real I2C device address and 256-byte word offset (i.e. MSB part of offset). And "addr[1]" only carries lower 8 bit of offset. So I would recommend to separate 2 invocations of "i2c_{read|write}": 1) for "CONFIG_SYS_I2C_EEPROM_ADDR_LEN = 1" 2) for "CONFIG_SYS_I2C_EEPROM_ADDR_LEN > 1" -Alexey > > 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 02539c4..0edc259 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], addr[1], alen-1, buffer, len) != 0) > + if (i2c_read (dev_addr, offset, 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], addr[1], alen-1, buffer, len) != 0) > + if (i2c_write (dev_addr, offset, alen-1, buffer, len) != 0) > rcode = 1; > > #endif > -- > 1.7.9.5 > _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot