diff mbox

i2c: recovery: directly exit when SCL is stuck low

Message ID 20180630170813.13194-1-wsa+renesas@sang-engineering.com (mailing list archive)
State Under Review
Delegated to: Geert Uytterhoeven
Headers show

Commit Message

Wolfram Sang June 30, 2018, 5:08 p.m. UTC
If SCL is stuck low, the bus cannot be recovered. No need to check SDA
or futilely trying to send a STOP. Just exit.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/i2c/i2c-core-base.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index bfefeb2ab2fd..cbbfe3fd387b 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -189,7 +189,7 @@  int i2c_generic_scl_recovery(struct i2c_adapter *adap)
 				dev_err(&adap->dev,
 					"SCL is stuck low, exit recovery\n");
 				ret = -EBUSY;
-				break;
+				goto exit_unprepare;
 			}
 			/* Break if SDA is high */
 			if (bri->get_sda && bri->get_sda(adap))
@@ -227,6 +227,7 @@  int i2c_generic_scl_recovery(struct i2c_adapter *adap)
 		ndelay(RECOVERY_NDELAY / 2);
 	}
 
+ exit_unprepare:
 	if (bri->unprepare_recovery)
 		bri->unprepare_recovery(adap);