aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/busses/i2c-pca-isa.c
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
commit2378bc09b91b0702fac7823828a614fd8016a29f (patch)
tree26539b17077028baba2741cf0e78fc01225a7d36 /drivers/i2c/busses/i2c-pca-isa.c
parent8e99ada8deaa9033600cd2c7d0a9366b0e99ab68 (diff)
i2c-algo-pca: Use timeout for checking the state machine
We now timeout also if the state machine does not change within the given time. For that, the driver-specific completion-functions are extended to return true or false depending on the timeout. This then gets checked in the algorithm. Signed-off-by: Wolfram Sang <w.sang@pengutronix.de> Signed-off-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/i2c/busses/i2c-pca-isa.c')
-rw-r--r--drivers/i2c/busses/i2c-pca-isa.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/drivers/i2c/busses/i2c-pca-isa.c b/drivers/i2c/busses/i2c-pca-isa.c
index b9403fdfb6d8..0ed68e2ccd22 100644
--- a/drivers/i2c/busses/i2c-pca-isa.c
+++ b/drivers/i2c/busses/i2c-pca-isa.c
@@ -23,6 +23,7 @@
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/moduleparam.h> 24#include <linux/moduleparam.h>
25#include <linux/delay.h> 25#include <linux/delay.h>
26#include <linux/jiffies.h>
26#include <linux/init.h> 27#include <linux/init.h>
27#include <linux/interrupt.h> 28#include <linux/interrupt.h>
28#include <linux/wait.h> 29#include <linux/wait.h>
@@ -43,6 +44,7 @@ static int irq = -1;
43 * in the actual clock rate */ 44 * in the actual clock rate */
44static int clock = 59000; 45static int clock = 59000;
45 46
47static struct i2c_adapter pca_isa_ops;
46static wait_queue_head_t pca_wait; 48static wait_queue_head_t pca_wait;
47 49
48static void pca_isa_writebyte(void *pd, int reg, int val) 50static void pca_isa_writebyte(void *pd, int reg, int val)
@@ -69,16 +71,22 @@ static int pca_isa_readbyte(void *pd, int reg)
69 71
70static int pca_isa_waitforcompletion(void *pd) 72static int pca_isa_waitforcompletion(void *pd)
71{ 73{
72 int ret = 0; 74 long ret = ~0;
75 unsigned long timeout;
73 76
74 if (irq > -1) { 77 if (irq > -1) {
75 ret = wait_event_interruptible(pca_wait, 78 ret = wait_event_interruptible_timeout(pca_wait,
76 pca_isa_readbyte(pd, I2C_PCA_CON) & I2C_PCA_CON_SI); 79 pca_isa_readbyte(pd, I2C_PCA_CON)
80 & I2C_PCA_CON_SI, pca_isa_ops.timeout);
77 } else { 81 } else {
78 while ((pca_isa_readbyte(pd, I2C_PCA_CON) & I2C_PCA_CON_SI) == 0) 82 /* Do polling */
83 timeout = jiffies + pca_isa_ops.timeout;
84 while (((pca_isa_readbyte(pd, I2C_PCA_CON)
85 & I2C_PCA_CON_SI) == 0)
86 && (ret = time_before(jiffies, timeout)))
79 udelay(100); 87 udelay(100);
80 } 88 }
81 return ret; 89 return ret > 0;
82} 90}
83 91
84static void pca_isa_resetchip(void *pd) 92static void pca_isa_resetchip(void *pd)