aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/algos/i2c-algo-pcf.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/drivers/i2c/algos/i2c-algo-pcf.c b/drivers/i2c/algos/i2c-algo-pcf.c
index 5906986d013b..65a769f3ae79 100644
--- a/drivers/i2c/algos/i2c-algo-pcf.c
+++ b/drivers/i2c/algos/i2c-algo-pcf.c
@@ -115,15 +115,17 @@ static int wait_for_bb(struct i2c_algo_pcf_data *adap)
115 115
116 status = get_pcf(adap, 1); 116 status = get_pcf(adap, 1);
117 117
118 while (timeout-- && !(status & I2C_PCF_BB)) { 118 while (!(status & I2C_PCF_BB) && --timeout) {
119 udelay(100); /* wait for 100 us */ 119 udelay(100); /* wait for 100 us */
120 status = get_pcf(adap, 1); 120 status = get_pcf(adap, 1);
121 } 121 }
122 122
123 if (timeout <= 0) 123 if (timeout == 0) {
124 printk(KERN_ERR "Timeout waiting for Bus Busy\n"); 124 printk(KERN_ERR "Timeout waiting for Bus Busy\n");
125 return -ETIMEDOUT;
126 }
125 127
126 return timeout <= 0; 128 return 0;
127} 129}
128 130
129static int wait_for_pin(struct i2c_algo_pcf_data *adap, int *status) 131static int wait_for_pin(struct i2c_algo_pcf_data *adap, int *status)
@@ -133,7 +135,7 @@ static int wait_for_pin(struct i2c_algo_pcf_data *adap, int *status)
133 135
134 *status = get_pcf(adap, 1); 136 *status = get_pcf(adap, 1);
135 137
136 while (timeout-- && (*status & I2C_PCF_PIN)) { 138 while ((*status & I2C_PCF_PIN) && --timeout) {
137 adap->waitforpin(adap->data); 139 adap->waitforpin(adap->data);
138 *status = get_pcf(adap, 1); 140 *status = get_pcf(adap, 1);
139 } 141 }
@@ -142,10 +144,10 @@ static int wait_for_pin(struct i2c_algo_pcf_data *adap, int *status)
142 return -EINTR; 144 return -EINTR;
143 } 145 }
144 146
145 if (timeout <= 0) 147 if (timeout == 0)
146 return -1; 148 return -ETIMEDOUT;
147 else 149
148 return 0; 150 return 0;
149} 151}
150 152
151/* 153/*