Skip to content

Commit

Permalink
i2c: i2c-bfin-twi: Break dead waiting loop if i2c device misbehaves.
Browse files Browse the repository at this point in the history
Some fault i2c device may hold the sda/scl line and cause i2c driver
wait in the BUS busy loop. The I2C framework already retry the
transfer loop before timeout. Return -EAGAIN instead of pull BUSBUSY
in the other loop.

Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
  • Loading branch information
Sonic Zhang authored and Wolfram Sang committed Jul 13, 2012
1 parent a20a64d commit a25733d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions drivers/i2c/busses/i2c-bfin-twi.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,8 @@ static int bfin_twi_do_master_xfer(struct i2c_adapter *adap,
if (!(read_CONTROL(iface) & TWI_ENA))
return -ENXIO;

while (read_MASTER_STAT(iface) & BUSBUSY)
yield();
if (read_MASTER_STAT(iface) & BUSBUSY)
return -EAGAIN;

iface->pmsg = msgs;
iface->msg_num = num;
Expand Down Expand Up @@ -407,8 +407,8 @@ int bfin_twi_do_smbus_xfer(struct i2c_adapter *adap, u16 addr,
if (!(read_CONTROL(iface) & TWI_ENA))
return -ENXIO;

while (read_MASTER_STAT(iface) & BUSBUSY)
yield();
if (read_MASTER_STAT(iface) & BUSBUSY)
return -EAGAIN;

iface->writeNum = 0;
iface->readNum = 0;
Expand Down

0 comments on commit a25733d

Please sign in to comment.