summaryrefslogtreecommitdiffstats
path: root/drivers/i2c
diff options
context:
space:
mode:
authorWolfram Sang <wsa+renesas@sang-engineering.com>2018-07-10 23:42:16 +0200
committerWolfram Sang <wsa@the-dreams.de>2018-07-17 10:41:55 +0200
commitffc59c496bf8498657321c59433f55bbcf2d9c38 (patch)
tree9dc18ae36f5b5d1ad5e8b9195d2b7e5ef181307c /drivers/i2c
parentMerge tag 'v4.18-rc5' into i2c/for-4.19 (diff)
downloadlinux-ffc59c496bf8498657321c59433f55bbcf2d9c38.tar.xz
linux-ffc59c496bf8498657321c59433f55bbcf2d9c38.zip
i2c: recovery: require either get_sda or set_sda
For bus recovery, we either need to bail out early if we can read SDA or we need to send STOP after every pulse. Otherwise recovery might be misinterpreted as an unwanted write. So, require one of those SDA handling functions to avoid this problem. Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Acked-by: Peter Rosin <peda@axentia.se> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/i2c-core-base.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index 301285c54603..871a9731894f 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -202,7 +202,8 @@ int i2c_generic_scl_recovery(struct i2c_adapter *adap)
/*
* If we can set SDA, we will always create STOP here to ensure
* the additional pulses will do no harm. This is achieved by
- * letting SDA follow SCL half a cycle later.
+ * letting SDA follow SCL half a cycle later. Check the
+ * 'incomplete_write_byte' fault injector for details.
*/
ndelay(RECOVERY_NDELAY / 2);
if (bri->set_sda)
@@ -274,6 +275,10 @@ static void i2c_init_recovery(struct i2c_adapter *adap)
err_str = "no {get|set}_scl() found";
goto err;
}
+ if (!bri->set_sda && !bri->get_sda) {
+ err_str = "either get_sda() or set_sda() needed";
+ goto err;
+ }
}
return;