i2c: i2c-bfin-twi: Break dead waiting loop if i2c device misbehaves.
authorSonic Zhang <sonic.zhang@analog.com>
Wed, 13 Jun 2012 08:22:42 +0000 (16:22 +0800)
committerWolfram Sang <w.sang@pengutronix.de>
Fri, 13 Jul 2012 06:27:31 +0000 (08:27 +0200)
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>
drivers/i2c/busses/i2c-bfin-twi.c

index 4799c68869462d003b9b5bd732645716d6339941..5fb5f3ee13a2a092c207601496b4f5317a64dbb6 100644 (file)
@@ -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;
@@ -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;
This page took 0.03128 seconds and 5 git commands to generate.