]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
ARM: OMAP: Fix occasional i2c driver hang
authorJason Marini <jason.marini@gmail.com>
Thu, 28 Aug 2008 19:30:58 +0000 (15:30 -0400)
committerTony Lindgren <tony@atomide.com>
Wed, 10 Sep 2008 20:40:11 +0000 (13:40 -0700)
The i2c driver contains a while loop that has no timeout.  If i2c is in a
funky state and OMAP_I2C_CON_STT remains asserted, the kernel hangs.  Insert
the standard i2c timeout into the loop.

Signed-off-by: Jason P Marini <jason.marini@gmail.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
drivers/i2c/busses/i2c-omap.c

index 5058a47e98225ad66fa0b78d9fe471c994fca0e3..0f7cbe8f5cefc7e11d239efd55d4f913cad9efa5 100644 (file)
@@ -440,9 +440,16 @@ static int omap_i2c_xfer_msg(struct i2c_adapter *adap,
        omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, w);
 
        if (dev->b_hw && stop) {
+               unsigned long delay = jiffies + OMAP_I2C_TIMEOUT;
+
                /* H/w behavior: dont write stt and stp together.. */
                while (omap_i2c_read_reg(dev, OMAP_I2C_CON_REG) & OMAP_I2C_CON_STT) {
-                       /* Dont do anything - this will come in a couple of loops at max*/
+                       /* Let the user know if i2c is in a bad state */
+                       if (time_after (jiffies, delay)) {
+                               dev_err(dev->dev, "controller timed out "
+                               "waiting for start condition to finish\n");
+                               return -ETIMEDOUT;
+                       }
                }
                w |= OMAP_I2C_CON_STP;
                w &= ~OMAP_I2C_CON_STT;