commit: http://blackfin.uclinux.org/git/?p=linux-kernel;a=commitdiff;h=45978af423c5bccb24e68ab20504ebc6cae4d4e8
branch: http://blackfin.uclinux.org/git/?p=linux-kernel;a=shortlog;h=refs/heads/trunk

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 <[email protected]>
---
 drivers/i2c/busses/i2c-bfin-twi.c |   18 ++++--------------
 1 files changed, 4 insertions(+), 14 deletions(-)

diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c
index bb9dde7..e1abf50 100644
--- a/drivers/i2c/busses/i2c-bfin-twi.c
+++ b/drivers/i2c/busses/i2c-bfin-twi.c
@@ -247,8 +247,6 @@ static irqreturn_t bfin_twi_interrupt_entry(int irq, void *dev_id)
 	return IRQ_HANDLED;
 }
 
-#define BFIN_TWI_BUSY_TIMEOUT	1000
-
 /*
  * One i2c master transfer
  */
@@ -258,16 +256,12 @@ static int bfin_twi_do_master_xfer(struct i2c_adapter *adap,
 	struct bfin_twi_iface *iface = adap->algo_data;
 	struct i2c_msg *pmsg;
 	int rc = 0;
-	unsigned int busy_timeout = BFIN_TWI_BUSY_TIMEOUT;
 
 	if (!(read_CONTROL(iface) & TWI_ENA))
 		return -ENXIO;
 
-	while (read_MASTER_STAT(iface) & BUSBUSY) {
-		if (--busy_timeout == 0)
-			return -EBUSY;
-		yield();
-	}
+	if (read_MASTER_STAT(iface) & BUSBUSY)
+		return -EAGAIN;
 
 	iface->pmsg = msgs;
 	iface->msg_num = num;
@@ -364,16 +358,12 @@ int bfin_twi_do_smbus_xfer(struct i2c_adapter *adap, u16 addr,
 {
 	struct bfin_twi_iface *iface = adap->algo_data;
 	int rc = 0;
-	unsigned int busy_timeout = BFIN_TWI_BUSY_TIMEOUT;
 
 	if (!(read_CONTROL(iface) & TWI_ENA))
 		return -ENXIO;
 
-	while (read_MASTER_STAT(iface) & BUSBUSY) {
-		if (--busy_timeout == 0)
-			return -EBUSY;
-		yield();
-	}
+	if (read_MASTER_STAT(iface) & BUSBUSY)
+		return -EAGAIN;
 
 	iface->writeNum = 0;
 	iface->readNum = 0;
_______________________________________________
Linux-kernel-commits mailing list
[email protected]
https://blackfin.uclinux.org/mailman/listinfo/linux-kernel-commits

Reply via email to