aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorIan Campbell <icampbell@arcom.com>2005-08-10 03:51:16 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2005-09-05 12:14:15 -0400
commit48edcb65ddcd93b6421831ad133599aacea9724a (patch)
tree8897c3568fc5f6651fa0ddb80d7e60a8ca2adef4 /drivers
parentcdcb19219714c796ddef1202e952566c5f86354d (diff)
[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: Ian Campbell <icampbell@arcom.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/i2c/algos/i2c-algo-pca.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/drivers/i2c/algos/i2c-algo-pca.c b/drivers/i2c/algos/i2c-algo-pca.c
index cc3a952401f2..ff2db0da4417 100644
--- a/drivers/i2c/algos/i2c-algo-pca.c
+++ b/drivers/i2c/algos/i2c-algo-pca.c
@@ -187,12 +187,14 @@ static int pca_xfer(struct i2c_adapter *i2c_adap,
187 int numbytes = 0; 187 int numbytes = 0;
188 int state; 188 int state;
189 int ret; 189 int ret;
190 int timeout = 100;
190 191
191 state = pca_status(adap); 192 while ((state = pca_status(adap)) != 0xf8 && timeout--) {
192 if ( state != 0xF8 ) { 193 msleep(10);
193 dev_dbg(&i2c_adap->dev, "bus is not idle. status is %#04x\n", state ); 194 }
194 /* FIXME: what to do. Force stop ? */ 195 if (state != 0xf8) {
195 return -EREMOTEIO; 196 dev_dbg(&i2c_adap->dev, "bus is not idle. status is %#04x\n", state);
197 return -EIO;
196 } 198 }
197 199
198 DEB1("{{{ XFER %d messages\n", num); 200 DEB1("{{{ XFER %d messages\n", num);