提交 b778c1b5 编写于 作者: R Reinhard Pfau 提交者: Andy Fleming

i2c: fsl_i2c: i2c_read(): dont try to write address w/ alen=0

if alen is 0: no longer start a write cycle before reading data.
Signed-off-by: NDirk Eibach <dirk.eibach@gdsys.cc>
Signed-off-by: NReinhard Pfau <reinhard.pfau@gdsys.cc>
Acked-by: NHeiko Schocher <hs@denx.de>
Signed-off-by: NAndy Fleming <afleming@freescale.com>
上级 be6c1529
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册