1 From: Russell King <rmk+kernel@armlinux.org.uk>
2 Bcc: linux@mail.armlinux.org.uk
3 Cc: linux-i2c@vger.kernel.org
4 Subject: [PATCH 12/17] i2c: pxa: fix i2c_pxa_wait_bus_not_busy() boundary
7 Content-Disposition: inline
8 Content-Transfer-Encoding: 8bit
9 Content-Type: text/plain; charset="utf-8"
11 Fix i2c_pxa_wait_bus_not_busy()'s boundary conditions, so that a
12 coincidental success and timeout results in the function returning
15 Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
17 drivers/i2c/busses/i2c-pxa.c | 17 ++++++++++++-----
18 1 file changed, 12 insertions(+), 5 deletions(-)
20 diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
21 index b2c7765756e2..19505ffbb8f1 100644
22 --- a/drivers/i2c/busses/i2c-pxa.c
23 +++ b/drivers/i2c/busses/i2c-pxa.c
24 @@ -417,19 +417,26 @@ static void i2c_pxa_abort(struct pxa_i2c *i2c)
25 static int i2c_pxa_wait_bus_not_busy(struct pxa_i2c *i2c)
27 int timeout = DEF_TIMEOUT;
30 - while (timeout-- && readl(_ISR(i2c)) & (ISR_IBB | ISR_UB)) {
31 - if ((readl(_ISR(i2c)) & ISR_SAD) != 0)
33 + isr = readl(_ISR(i2c));
34 + if (!(isr & (ISR_IBB | ISR_UB)))
51 - return timeout < 0 ? I2C_RETRY : 0;
55 static int i2c_pxa_wait_master(struct pxa_i2c *i2c)