]> git.sur5r.net Git - u-boot/commitdiff
i2c: lpc32xx: fix read timeout
authorSylvain Lemieux <slemieux@tycoint.com>
Mon, 27 Jul 2015 17:37:38 +0000 (13:37 -0400)
committerTom Rini <trini@konsulko.com>
Mon, 17 Aug 2015 12:11:49 +0000 (08:11 -0400)
Fix a condition that generate watchdog timeout inside "lpc32xx_i2c_read" when parameters alen != 0 and len = 0.

Signed-off-by: Sylvain Lemieux <slemieux@tycoint.com>
drivers/i2c/lpc32xx_i2c.c

index 98106fa988287a3b108391e677f2ee8ab429007d..4c66769103bf617d7e3201ffd7bf82ce9ed0512b 100644 (file)
@@ -172,12 +172,12 @@ static int lpc32xx_i2c_read(struct i2c_adapter *adap, u8 dev, uint addr,
                                *(data++) = readl(&i2c->rx);
                        }
                }
+               /* wait for end of transation */
+               while (!((stat = readl(&i2c->stat)) & LPC32XX_I2C_STAT_TDI))
+                       ;
+               /* clear end-of-transaction flag */
+               writel(1, &i2c->stat);
        }
-       /* wait for end of transation */
-       while (!((stat = readl(&i2c->stat)) & LPC32XX_I2C_STAT_TDI))
-               ;
-       /* clear end-of-transaction flag */
-       writel(1, &i2c->stat);
        /* success */
        return 0;
 }