Skip to content

Commit

Permalink
i2c-pxa.c: timeouts off by 1
Browse files Browse the repository at this point in the history
With `while (timeout--)' timeout reaches -1 after the loop, so the tests
below are off by one.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Acked-by: Wolfram Sang <w.sang@pengutronix.de>
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
  • Loading branch information
Roel Kluin authored and Ben Dooks committed May 3, 2009
1 parent 091438d commit d10db3a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/i2c/busses/i2c-pxa.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit d10db3a

Please sign in to comment.