[U-Boot] [PATCH] Allow 0-len address bytes (non SMBus) for i2c transactions in fsl driver

Piergiorgio Beruto piergiorgio.beruto at gmail.com
Tue Jan 4 14:34:05 CET 2011


---
 drivers/i2c/fsl_i2c.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/i2c/fsl_i2c.c b/drivers/i2c/fsl_i2c.c
index cb13dee..8350fbe 100644
--- a/drivers/i2c/fsl_i2c.c
+++ b/drivers/i2c/fsl_i2c.c
@@ -381,12 +381,12 @@ i2c_read(u8 dev, uint addr, int alen, u8 *data,
int length)
 	u8 *a = (u8*)&addr;

 	if (i2c_wait4bus() >= 0
-	    && i2c_write_addr(dev, I2C_WRITE_BIT, 0) != 0
-	    && __i2c_write(&a[4 - alen], alen) == alen)
+	    && (alen == 0 || (i2c_write_addr(dev, I2C_WRITE_BIT, 0) != 0
+	    && __i2c_write(&a[4 - alen], alen) == alen)))
 		i = 0; /* No error so far */

 	if (length
-	    && i2c_write_addr(dev, I2C_READ_BIT, 1) != 0)
+	    && i2c_write_addr(dev, I2C_READ_BIT, alen == 0 ? 0 : 1) != 0)
 		i = __i2c_read(data, length);

 	writeb(I2C_CR_MEN, &i2c_dev[i2c_bus_num]->cr);
@@ -432,7 +432,7 @@ i2c_probe(uchar chip)
 	if (chip == (readb(&i2c_dev[i2c_bus_num]->adr) >> 1))
 		return -1;

-	return i2c_read(chip, 0, 0, NULL, 0);
+	return i2c_read(chip, 0, 1, NULL, 0);
 }

 int i2c_set_bus_num(unsigned int bus)
-- 
1.5.4.3


More information about the U-Boot mailing list