[PATCH] i2c-pxa.c: timeouts off by 1

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

 



Jean Delvare wrote:
> Hi Roel,
> 
> Sorry for the late reply, I overlooked your patch.
> 
> On Wed, 25 Feb 2009 12:00:52 +0100, Roel Kluin wrote:
>> with while (timeout++ < MAX_TIMEOUT); timeout reaches MAX_TIMEOUT + 1 after the
>> loop, so the tests below are off by one.
> 
> This is correct. It just shows how all PC SMBus master drivers have
> been copied from each other ;)

>> --- a/drivers/i2c/busses/i2c-pxa.c
>> +++ b/drivers/i2c/busses/i2c-pxa.c
>> @@ -264,10 +264,10 @@ static int i2c_pxa_wait_bus_not_busy(struct pxa_i2c *i2c)
>>  		show_state(i2c);
>>  	}
>>  
>> -	if (timeout <= 0)
>> +	if (timeout < 0)
>>  		show_state(i2c);
>>  
>> -	return timeout <= 0 ? I2C_RETRY : 0;
>> +	return timeout < 0 ? I2C_RETRY : 0;
>>  }
>>  
> 
> This one is different and doesn't match the description. I'm excluding
> it from this patch, for this reason and also because there may be other
> i2c-pxa patches pending on the arm side. Can you please submit a
> separate patch for i2c-pxa? Thanks.

Ok, here's for drivers/i2c/busses/i2c-pxa.c. Note that I found another,
the last hunk.
--------------------------->8-------------8<------------------------------
With `while (timeout--)' timeout reaches -1 after the loop, so the tests
below are off by one.

Signed-off-by: Roel Kluin <roel.kluin@xxxxxxxxx>
---
diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index c1405c8..acc7143 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -265,10 +265,10 @@ static int i2c_pxa_wait_bus_not_busy(struct pxa_i2c *i2c)
 		show_state(i2c);
 	}
 
-	if (timeout <= 0)
+	if (timeout < 0)
 		show_state(i2c);
 
-	return timeout <= 0 ? I2C_RETRY : 0;
+	return timeout < 0 ? I2C_RETRY : 0;
 }
 
 static int i2c_pxa_wait_master(struct pxa_i2c *i2c)
@@ -612,7 +612,7 @@ static int i2c_pxa_pio_set_master(struct pxa_i2c *i2c)
 		show_state(i2c);
 	}
 
-	if (timeout <= 0) {
+	if (timeout < 0) {
 		show_state(i2c);
 		dev_err(&i2c->adap.dev,
 			"i2c_pxa: timeout waiting for bus free\n");

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