i2c-algo-bit: Fix spurious SCL timeouts under heavy load
[linux-2.6-block.git] / drivers / i2c / algos / i2c-algo-bit.c
index 525c7345fa0b904242a0ef10a5d9502ab5e4baf1..24f94f4ae3954da741329e2b78aac43cc655ca23 100644 (file)
@@ -103,8 +103,14 @@ static int sclhi(struct i2c_algo_bit_data *adap)
                 * chips may hold it low ("clock stretching") while they
                 * are processing data internally.
                 */
-               if (time_after(jiffies, start + adap->timeout))
+               if (time_after(jiffies, start + adap->timeout)) {
+                       /* Test one last time, as we may have been preempted
+                        * between last check and timeout test.
+                        */
+                       if (getscl(adap))
+                               break;
                        return -ETIMEDOUT;
+               }
                cond_resched();
        }
 #ifdef DEBUG