Re: [PATCH] i2c: timeouts reach -1

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

 



On Sat, 31 Jan 2009 22:10:43 +0100, Jean Delvare wrote:
> Hi Roel,
> 
> On Sat, 31 Jan 2009 11:22:58 +0100, Roel Kluin wrote:
> > With a postfix decrement these timeouts reach -1 rather than 0,
> > but after the loop it is tested whether they have become 0.
> > 
> > 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 6af6814..6379ec1 100644
> > --- a/drivers/i2c/busses/i2c-pxa.c
> > +++ b/drivers/i2c/busses/i2c-pxa.c
> > @@ -644,7 +644,7 @@ static int i2c_pxa_do_pio_xfer(struct pxa_i2c *i2c,
> >  
> >  	i2c_pxa_start_message(i2c);
> >  
> > -	while (timeout-- && i2c->msg_num > 0) {
> > +	while (--timeout && i2c->msg_num > 0) {
> >  		i2c_pxa_handler(0, i2c);
> >  		udelay(10);
> >  	}
> 
> Good catch. Applied, thanks for reporting.

On second thought, shouldn't the msg_num test be done first and the
timeout test second? With the current order, you could exit with a
timeout error while all the messages were successfully transferred.

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