Re: [U-Boot] [PATCH v6 2/5] i2c: fsl_i2c: i2c_read(): dont try to write address w/ alen=0

2013-06-19 Thread Heiko Schocher
Hello Dirk,

Am 12.06.2013 10:08, schrieb dirk.eib...@gdsys.cc:
> From: Reinhard Pfau 
> 
> if alen is 0: no longer start a write cycle before reading data.
> 
> Signed-off-by: Dirk Eibach 
> Signed-off-by: Reinhard Pfau 
> 
> 
> Signed-off-by: Dirk Eibach 
> ---
> Changes in v6: None
> Changes in v5:
> - fix i2c_probe
> 
> Changes in v4: None
> Changes in v3: None
> Changes in v2:
> - whitespace fixes
> 
>  drivers/i2c/fsl_i2c.c | 9 ++---
>  1 file changed, 6 insertions(+), 3 deletions(-)

As it is in a patch serie:

Acked-by: Heiko Schocher 

bye,
Heiko
-- 
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v6 2/5] i2c: fsl_i2c: i2c_read(): dont try to write address w/ alen=0

2013-06-12 Thread dirk . eibach
From: Reinhard Pfau 

if alen is 0: no longer start a write cycle before reading data.

Signed-off-by: Dirk Eibach 
Signed-off-by: Reinhard Pfau 


Signed-off-by: Dirk Eibach 
---
Changes in v6: None
Changes in v5:
- fix i2c_probe

Changes in v4: None
Changes in v3: None
Changes in v2:
- whitespace fixes

 drivers/i2c/fsl_i2c.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/fsl_i2c.c b/drivers/i2c/fsl_i2c.c
index 1c7265d..5d7e010 100644
--- a/drivers/i2c/fsl_i2c.c
+++ b/drivers/i2c/fsl_i2c.c
@@ -383,13 +383,16 @@ i2c_read(u8 dev, uint addr, int alen, u8 *data, int 
length)
int i = -1; /* signal error */
u8 *a = (u8*)&addr;
 
-   if (i2c_wait4bus() >= 0
+   if (i2c_wait4bus() < 0)
+   return -1;
+
+   if ((!length || 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)
+   if (length &&
+   i2c_write_addr(dev, I2C_READ_BIT, alen ? 1 : 0) != 0)
i = __i2c_read(data, length);
 
writeb(I2C_CR_MEN, &i2c_dev[i2c_bus_num]->cr);
-- 
1.8.3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot