aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/algos
diff options
context:
space:
mode:
authorWolfram Sang <w.sang@pengutronix.de>2009-03-28 16:34:45 -0400
committerJean Delvare <khali@linux-fr.org>2009-03-28 16:34:45 -0400
commit8e99ada8deaa9033600cd2c7d0a9366b0e99ab68 (patch)
tree20784a41011e58f7ba6497d7a3763781b8a3d460 /drivers/i2c/algos
parenteff9ec95efaaf6b12d230f0ea7d3c295d3bc9d57 (diff)
i2c-algo-pca: Rework waiting for a free bus
Waiting for a free bus now accepts the timeout value in jiffies and does proper checking using time_before. Signed-off-by: Wolfram Sang <w.sang@pengutronix.de> Signed-off-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/i2c/algos')
-rw-r--r--drivers/i2c/algos/i2c-algo-pca.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/drivers/i2c/algos/i2c-algo-pca.c b/drivers/i2c/algos/i2c-algo-pca.c
index a8e51bd1a4f5..9e134fad7bda 100644
--- a/drivers/i2c/algos/i2c-algo-pca.c
+++ b/drivers/i2c/algos/i2c-algo-pca.c
@@ -22,6 +22,7 @@
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/moduleparam.h> 23#include <linux/moduleparam.h>
24#include <linux/delay.h> 24#include <linux/delay.h>
25#include <linux/jiffies.h>
25#include <linux/init.h> 26#include <linux/init.h>
26#include <linux/errno.h> 27#include <linux/errno.h>
27#include <linux/i2c.h> 28#include <linux/i2c.h>
@@ -186,14 +187,16 @@ static int pca_xfer(struct i2c_adapter *i2c_adap,
186 int numbytes = 0; 187 int numbytes = 0;
187 int state; 188 int state;
188 int ret; 189 int ret;
189 int timeout = i2c_adap->timeout; 190 unsigned long timeout = jiffies + i2c_adap->timeout;
190 191
191 while ((state = pca_status(adap)) != 0xf8 && timeout--) { 192 while (pca_status(adap) != 0xf8) {
192 msleep(10); 193 if (time_before(jiffies, timeout)) {
193 } 194 msleep(10);
194 if (state != 0xf8) { 195 } else {
195 dev_dbg(&i2c_adap->dev, "bus is not idle. status is %#04x\n", state); 196 dev_dbg(&i2c_adap->dev, "bus is not idle. status is "
196 return -EAGAIN; 197 "%#04x\n", state);
198 return -EAGAIN;
199 }
197 } 200 }
198 201
199 DEB1("{{{ XFER %d messages\n", num); 202 DEB1("{{{ XFER %d messages\n", num);