Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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>

authored by

Ian Campbell and committed by
Greg Kroah-Hartman
48edcb65 cdcb1921

+7 -5
+7 -5
drivers/i2c/algos/i2c-algo-pca.c
··· 187 187 int numbytes = 0; 188 188 int state; 189 189 int ret; 190 + int timeout = 100; 190 191 191 - state = pca_status(adap); 192 - if ( state != 0xF8 ) { 193 - dev_dbg(&i2c_adap->dev, "bus is not idle. status is %#04x\n", state ); 194 - /* FIXME: what to do. Force stop ? */ 195 - return -EREMOTEIO; 192 + while ((state = pca_status(adap)) != 0xf8 && timeout--) { 193 + msleep(10); 194 + } 195 + if (state != 0xf8) { 196 + dev_dbg(&i2c_adap->dev, "bus is not idle. status is %#04x\n", state); 197 + return -EIO; 196 198 } 197 199 198 200 DEB1("{{{ XFER %d messages\n", num);