Commit e896be5a authored by Russell King's avatar Russell King Committed by Wolfram Sang

i2c: pxa: fix i2c_pxa_wait_bus_not_busy() boundary condition

Fix i2c_pxa_wait_bus_not_busy()'s boundary conditions, so that a
coincidental success and timeout results in the function returning
success.
Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: default avatarWolfram Sang <wsa@kernel.org>
parent bb82ba69
...@@ -416,19 +416,26 @@ static void i2c_pxa_abort(struct pxa_i2c *i2c) ...@@ -416,19 +416,26 @@ static void i2c_pxa_abort(struct pxa_i2c *i2c)
static int i2c_pxa_wait_bus_not_busy(struct pxa_i2c *i2c) static int i2c_pxa_wait_bus_not_busy(struct pxa_i2c *i2c)
{ {
int timeout = DEF_TIMEOUT; int timeout = DEF_TIMEOUT;
u32 isr;
while (timeout-- && readl(_ISR(i2c)) & (ISR_IBB | ISR_UB)) { while (1) {
if ((readl(_ISR(i2c)) & ISR_SAD) != 0) isr = readl(_ISR(i2c));
if (!(isr & (ISR_IBB | ISR_UB)))
return 0;
if (isr & ISR_SAD)
timeout += 4; timeout += 4;
if (!timeout--)
break;
msleep(2); msleep(2);
show_state(i2c); show_state(i2c);
} }
if (timeout < 0) show_state(i2c);
show_state(i2c);
return timeout < 0 ? I2C_RETRY : 0; return I2C_RETRY;
} }
static int i2c_pxa_wait_master(struct pxa_i2c *i2c) static int i2c_pxa_wait_master(struct pxa_i2c *i2c)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment