i2c: Fix SCL unwedge logic

The current logic breaks out of the for() loop if SCL gets unwedged
(goes high), but still falls through to the "I2C unwedge failed,
SCL is being held low" case.  Fix this so that we only hit the
"SCL is being held low" case if SCL actually is stuck low.

BUG=none
BRANCH=None
TEST=compile-test only, on samus

Change-Id: I39df1966dc25517ee03a56109e7d0b740c5ca12b
Signed-off-by: Kevin Cernekee <cernekee@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/295043
Reviewed-by: Randall Spangler <rspangler@chromium.org>
This commit is contained in:
Kevin Cernekee
2015-08-21 10:46:00 -07:00
committed by ChromeOS Commit Bot
parent ad8ce3f806
commit 5ca252d4ef

View File

@@ -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))