[U-Boot] [PATCH v3 4/4] cmd_eeprom: bug fix for i2c read/write

Alexey Brodkin Alexey.Brodkin at synopsys.com
Mon Dec 2 12:09:54 CET 2013


On Mon, 2013-12-02 at 16:02 +0800, Kuo-Jung Su wrote:
> From: Kuo-Jung Su <dantesu at faraday-tech.com>

> diff --git a/common/cmd_eeprom.c b/common/cmd_eeprom.c
> index 02539c4..3924805 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(addr[0], offset, alen - 1, buffer, len))
>  			rcode = 1;
>  #endif
>  		buffer += len;

I think this change is whether incomplete or improper.
Let's look at source code above line 161:
=============================
 125 #if CONFIG_SYS_I2C_EEPROM_ADDR_LEN == 1 && !defined(CONFIG_SPI_X)
 126                 uchar addr[2];
 127 
 128                 blk_off = offset & 0xFF;        /* block offset */
 129 
 130                 addr[0] = offset >> 8;          /* block number */
 131                 addr[1] = blk_off;              /* block offset */
 132                 alen    = 2;
 133 #else
 134                 uchar addr[3];
 135 
 136                 blk_off = offset & 0xFF;        /* block offset */
 137 
 138                 addr[0] = offset >> 16;         /* block number */
 139                 addr[1] = offset >>  8;         /* upper address
octet */
 140                 addr[2] = blk_off;              /* lower address
octet */
 141                 alen    = 3;
 142 #endif  /* CONFIG_SYS_I2C_EEPROM_ADDR_LEN, CONFIG_SPI_X */
 143 
 144                 addr[0] |= dev_addr;            /* insert device
address */
=============================



More information about the U-Boot mailing list