summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/i2c.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/common/i2c.c b/common/i2c.c
index 3f9b586bb4..24f0d95354 100644
--- a/common/i2c.c
+++ b/common/i2c.c
@@ -391,19 +391,20 @@ int i2c_unwedge(int port)
* by a slave.
*/
if (!i2c_raw_get_scl(port)) {
- for (i = 0; i < UNWEDGE_SCL_ATTEMPTS; i++) {
+ for (i = 0;; i++) {
+ if (i >= UNWEDGE_SCL_ATTEMPTS) {
+ /*
+ * If we get here, a slave is holding the clock
+ * low and there is nothing we can do.
+ */
+ CPRINTS("I2C unwedge failed, SCL is being held low");
+ ret = EC_ERROR_UNKNOWN;
+ goto unwedge_done;
+ }
udelay(I2C_BITBANG_DELAY_US);
if (i2c_raw_get_scl(port))
break;
}
-
- /*
- * If we get here, a slave is holding the clock low and there
- * is nothing we can do.
- */
- CPRINTS("I2C unwedge failed, SCL is being held low");
- ret = EC_ERROR_UNKNOWN;
- goto unwedge_done;
}
if (i2c_raw_get_sda(port))