Skip to contentSkip to conversation

i2c: mvtwsi: Fix order of address bytes (high to low)

PATCH New Stefan Roese 1 participant 1 message Aug 25, 2016 I2C

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i2c: mvtwsi: Fix order of address bytes (high to low)

Patch f8a10ed1 [i2c: mvtwsi: Make address length variable] accidentally inverted the sequence of address bytes sent to the I2C device. This patch corrects this by sending the highest byte first and the lowest byte last again.

Tested on theadorable Armada-XP board.

Cc Mario Six <[email protected]>
Cc Heiko Schocher <[email protected]>
---
 drivers/i2c/mvtwsi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/i2c/mvtwsi.c +2 -2
index ab7481a..3765fed 100644
@@ -595,7 +595,7 @@ static int __twsi_i2c_read(struct mvtwsi_registers *twsi, uchar chip,
 		status = i2c_begin(twsi, expected_start, (chip << 1), tick);
 		/* Send address bytes */
 		while ((status == 0) && alen--)
-			status = twsi_send(twsi, *(addr++),
+			status = twsi_send(twsi, addr[alen],
 					   MVTWSI_STATUS_DATA_W_ACK, tick);
 		/* Send repeated STARTs after the initial START */
 		expected_start = MVTWSI_STATUS_REPEATED_START;
@@ -642,7 +642,7 @@ static int __twsi_i2c_write(struct mvtwsi_registers *twsi, uchar chip,
 	status = i2c_begin(twsi, MVTWSI_STATUS_START, (chip << 1), tick);
 	/* Send address bytes */
 	while ((status == 0) && (alen-- > 0))
-		status = twsi_send(twsi, *(addr++), MVTWSI_STATUS_DATA_W_ACK,
+		status = twsi_send(twsi, addr[alen], MVTWSI_STATUS_DATA_W_ACK,
 				   tick);
 	/* Send data bytes */
 	while ((status == 0) && (length-- > 0))
Signature · 1 line
2.9.3