[PATCH] i2c,algo: timeout reaches -1

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The postfix decrement decrements timeout till -1, but the
warning is already triggered on 0

Signed-off-by: Roel Kluin <roel.kluin@xxxxxxxxx>
---
diff --git a/drivers/i2c/algos/i2c-algo-pcf.c b/drivers/i2c/algos/i2c-algo-pcf.c
index 3e01992..0e2933f 100644
--- a/drivers/i2c/algos/i2c-algo-pcf.c
+++ b/drivers/i2c/algos/i2c-algo-pcf.c
@@ -115,7 +115,7 @@ static int wait_for_bb(struct i2c_algo_pcf_data *adap) {
 
 	status = get_pcf(adap, 1);
 #ifndef STUB_I2C
-	while (timeout-- && !(status & I2C_PCF_BB)) {
+	while (--timeout && !(status & I2C_PCF_BB)) {
 		udelay(100); /* wait for 100 us */
 		status = get_pcf(adap, 1);
 	}
@@ -123,7 +123,7 @@ static int wait_for_bb(struct i2c_algo_pcf_data *adap) {
 	if (timeout <= 0) {
 		printk(KERN_ERR "Timeout waiting for Bus Busy\n");
 	}
-	
+
 	return (timeout<=0);
 }
 
@@ -134,7 +134,7 @@ static int wait_for_pin(struct i2c_algo_pcf_data *adap, int *status) {
 
 	*status = get_pcf(adap, 1);
 #ifndef STUB_I2C
-	while (timeout-- && (*status & I2C_PCF_PIN)) {
+	while (--timeout && (*status & I2C_PCF_PIN)) {
 		adap->waitforpin(adap->data);
 		*status = get_pcf(adap, 1);
 	}
--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux