Commit 48edcb65 authored by Ian Campbell's avatar Ian Campbell Committed by Greg Kroah-Hartman

[PATCH] I2C: i2c-algo-pca -- gracefully handle a busy bus

I've been running with this patch for a while now, and while I've never
seen it trigger except with buggy hardware I think it is a cleaner way
to handle a busy bus. I had -EBUSY until about 10 minutes ago but -EIO
seems to be what most of the existing algo drivers will return in the
same circumstances.
Signed-off-by: default avatarIan Campbell <icampbell@arcom.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent cdcb1921
...@@ -187,12 +187,14 @@ static int pca_xfer(struct i2c_adapter *i2c_adap, ...@@ -187,12 +187,14 @@ static int pca_xfer(struct i2c_adapter *i2c_adap,
int numbytes = 0; int numbytes = 0;
int state; int state;
int ret; int ret;
int timeout = 100;
state = pca_status(adap); while ((state = pca_status(adap)) != 0xf8 && timeout--) {
if ( state != 0xF8 ) { msleep(10);
dev_dbg(&i2c_adap->dev, "bus is not idle. status is %#04x\n", state ); }
/* FIXME: what to do. Force stop ? */ if (state != 0xf8) {
return -EREMOTEIO; dev_dbg(&i2c_adap->dev, "bus is not idle. status is %#04x\n", state);
return -EIO;
} }
DEB1("{{{ XFER %d messages\n", num); DEB1("{{{ XFER %d messages\n", num);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment