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

login
register
mail settings
Submitter Piergiorgio Beruto
Date Jan. 4, 2011, 1:34 p.m.
Message ID <AANLkTikbJEy5vxy66Mm0agORWDjh_MNgEMBmjf1jVdbB@mail.gmail.com>
Download mbox | patch
Permalink /patch/77467/
State Changes Requested
Delegated to: Heiko Schocher
Headers show

Comments

Piergiorgio Beruto - Jan. 4, 2011, 1:34 p.m.
---
 drivers/i2c/fsl_i2c.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

 	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)

Patch

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);