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 --- a/drivers/i2c/busses/i2c-pxa.c
21 +++ b/drivers/i2c/busses/i2c-pxa.c
22 @@ -417,19 +417,26 @@ static void i2c_pxa_abort(struct pxa_i2c
23 static int i2c_pxa_wait_bus_not_busy(struct pxa_i2c *i2c)
25 int timeout = DEF_TIMEOUT;
28 - while (timeout-- && readl(_ISR(i2c)) & (ISR_IBB | ISR_UB)) {
29 - if ((readl(_ISR(i2c)) & ISR_SAD) != 0)
31 + isr = readl(_ISR(i2c));
32 + if (!(isr & (ISR_IBB | ISR_UB)))
49 - return timeout < 0 ? I2C_RETRY : 0;
53 static int i2c_pxa_wait_master(struct pxa_i2c *i2c)