diff mbox

[U-Boot] i2c: mv_i2c.c: Correct address endianness

Message ID 1481651393-24252-1-git-send-email-bradleybolen@gmail.com
State Accepted
Commit 77466267eb3f937f432135f73efb25122e668cfc
Delegated to: Heiko Schocher
Headers show

Commit Message

Bradley Bolen Dec. 13, 2016, 5:49 p.m. UTC
0c0f719ad2f46c8566a56daee37ebdb7c078c3b1 accidentally changed the
endianness of the i2c read and write addresses.  This was noticable when
accessing EEPROMs that use 2 byte addressing as the LSB was being sent
first.

Signed-off-by: Bradley Bolen <bradleybolen@gmail.com>
---
 drivers/i2c/mv_i2c.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Stefan Roese Dec. 19, 2016, 5:56 a.m. UTC | #1
On 13.12.2016 18:49, Bradley Bolen wrote:
> 0c0f719ad2f46c8566a56daee37ebdb7c078c3b1 accidentally changed the
> endianness of the i2c read and write addresses.  This was noticable when
> accessing EEPROMs that use 2 byte addressing as the LSB was being sent
> first.
>
> Signed-off-by: Bradley Bolen <bradleybolen@gmail.com>
> ---
>  drivers/i2c/mv_i2c.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/i2c/mv_i2c.c b/drivers/i2c/mv_i2c.c
> index 7f52fa2..c780272 100644
> --- a/drivers/i2c/mv_i2c.c
> +++ b/drivers/i2c/mv_i2c.c
> @@ -270,7 +270,7 @@ static int __i2c_read(struct mv_i2c *base, uchar chip, u8 *addr, int alen,
>  		msg.condition = I2C_COND_NORMAL;
>  		msg.acknack   = I2C_ACKNAK_WAITACK;
>  		msg.direction = I2C_WRITE;
> -		msg.data      = *(addr++);
> +		msg.data      = addr[alen];
>  		if (i2c_transfer(base, &msg))
>  			return -1;
>  	}
> @@ -341,7 +341,7 @@ static int __i2c_write(struct mv_i2c *base, uchar chip, u8 *addr, int alen,
>  		msg.condition = I2C_COND_NORMAL;
>  		msg.acknack   = I2C_ACKNAK_WAITACK;
>  		msg.direction = I2C_WRITE;
> -		msg.data      = *(addr++);
> +		msg.data      = addr[alen];
>  		if (i2c_transfer(base, &msg))
>  			return -1;
>  	}
>

Thanks for spotting:

Rewiewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan
Heiko Schocher Dec. 19, 2016, 6:22 a.m. UTC | #2
Hello Stefan,

Am 19.12.2016 um 06:56 schrieb Stefan Roese:
> On 13.12.2016 18:49, Bradley Bolen wrote:
>> 0c0f719ad2f46c8566a56daee37ebdb7c078c3b1 accidentally changed the
>> endianness of the i2c read and write addresses.  This was noticable when
>> accessing EEPROMs that use 2 byte addressing as the LSB was being sent
>> first.
>>
>> Signed-off-by: Bradley Bolen <bradleybolen@gmail.com>
>> ---
>>  drivers/i2c/mv_i2c.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/i2c/mv_i2c.c b/drivers/i2c/mv_i2c.c
>> index 7f52fa2..c780272 100644
>> --- a/drivers/i2c/mv_i2c.c
>> +++ b/drivers/i2c/mv_i2c.c
>> @@ -270,7 +270,7 @@ static int __i2c_read(struct mv_i2c *base, uchar chip, u8 *addr, int alen,
>>          msg.condition = I2C_COND_NORMAL;
>>          msg.acknack   = I2C_ACKNAK_WAITACK;
>>          msg.direction = I2C_WRITE;
>> -        msg.data      = *(addr++);
>> +        msg.data      = addr[alen];
>>          if (i2c_transfer(base, &msg))
>>              return -1;
>>      }
>> @@ -341,7 +341,7 @@ static int __i2c_write(struct mv_i2c *base, uchar chip, u8 *addr, int alen,
>>          msg.condition = I2C_COND_NORMAL;
>>          msg.acknack   = I2C_ACKNAK_WAITACK;
>>          msg.direction = I2C_WRITE;
>> -        msg.data      = *(addr++);
>> +        msg.data      = addr[alen];
>>          if (i2c_transfer(base, &msg))
>>              return -1;
>>      }
>>
>
> Thanks for spotting:
>
> Rewiewed-by: Stefan Roese <sr@denx.de>

Typo ... I fix this when applying this patch.

Thanks!

bye,
Heiko
diff mbox

Patch

diff --git a/drivers/i2c/mv_i2c.c b/drivers/i2c/mv_i2c.c
index 7f52fa2..c780272 100644
--- a/drivers/i2c/mv_i2c.c
+++ b/drivers/i2c/mv_i2c.c
@@ -270,7 +270,7 @@  static int __i2c_read(struct mv_i2c *base, uchar chip, u8 *addr, int alen,
 		msg.condition = I2C_COND_NORMAL;
 		msg.acknack   = I2C_ACKNAK_WAITACK;
 		msg.direction = I2C_WRITE;
-		msg.data      = *(addr++);
+		msg.data      = addr[alen];
 		if (i2c_transfer(base, &msg))
 			return -1;
 	}
@@ -341,7 +341,7 @@  static int __i2c_write(struct mv_i2c *base, uchar chip, u8 *addr, int alen,
 		msg.condition = I2C_COND_NORMAL;
 		msg.acknack   = I2C_ACKNAK_WAITACK;
 		msg.direction = I2C_WRITE;
-		msg.data      = *(addr++);
+		msg.data      = addr[alen];
 		if (i2c_transfer(base, &msg))
 			return -1;
 	}