Skip to contentSkip to conversation

i2c: core: only use set_scl for bus recovery after calling prepare_recovery

PATCH New Jan Luebbe 4 participants 4 messages Jul 8, 2015 – Jul 31, 2015

Subsystems (2)
lore
Share & tools
lore

Jan Luebbe

author
#0 lore raw

PATCH 1/1 i2c: core: only use set_scl for bus recovery after calling prepare_recovery

Using set_scl may be ineffective before calling the driver specific prepare_recovery callback, which might change into a test mode. So instead of setting SCL in i2c_generic_scl_recovery, move it to i2c_generic_recovery (after the optional prepare_recovery).

---
 drivers/i2c/i2c-core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/i2c/i2c-core.c +3 -1
index 069a41f116dd..be992b3e0be8 100644
@@ -567,6 +567,9 @@ static int i2c_generic_recovery(struct i2c_adapter *adap)
 	if (bri->prepare_recovery)
 		bri->prepare_recovery(adap);
 
+	bri->set_scl(adap, val);
+	ndelay(RECOVERY_NDELAY);
+
 	/*
 	 * By this time SCL is high, as we need to give 9 falling-rising edges
 	 */
@@ -597,7 +600,6 @@ static int i2c_generic_recovery(struct i2c_adapter *adap)
 
 int i2c_generic_scl_recovery(struct i2c_adapter *adap)
 {
-	adap->bus_recovery_info->set_scl(adap, 1);
 	return i2c_generic_recovery(adap);
 }
 EXPORT_SYMBOL_GPL(i2c_generic_scl_recovery);
Signature · 1 line
2.1.4
#1 lore raw

PATCH 1/1 i2c: core: only use set_scl for bus recovery after calling prepare_recovery

Hi!

Quoted 6 lines · ext Jan Luebbe

Using set_scl may be ineffective before calling the driver specific prepare_recovery callback, which might change into a test mode. So instead of setting SCL in i2c_generic_scl_recovery, move it to i2c_generic_recovery (after the optional prepare_recovery).

Makes sense,

Quoted 26 lines
---
 drivers/i2c/i2c-core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/i2c/i2c-core.c +3 -1
index 069a41f116dd..be992b3e0be8 100644
@@ -567,6 +567,9 @@ static int i2c_generic_recovery(struct i2c_adapter *adap)
 	if (bri->prepare_recovery)
 		bri->prepare_recovery(adap);
 
+	bri->set_scl(adap, val);
+	ndelay(RECOVERY_NDELAY);
+
 	/*
 	 * By this time SCL is high, as we need to give 9 falling-rising edges
 	 */
@@ -597,7 +600,6 @@ static int i2c_generic_recovery(struct i2c_adapter *adap)
 
 int i2c_generic_scl_recovery(struct i2c_adapter *adap)
 {
-	adap->bus_recovery_info->set_scl(adap, 1);
 	return i2c_generic_recovery(adap);
 }
 EXPORT_SYMBOL_GPL(i2c_generic_scl_recovery);
Signature · 2 lines
Best regards,
Alexander Sverdlin.
#2 lore raw

PATCH 1/1 i2c: core: only use set_scl for bus recovery after calling prepare_recovery

In reply to Jan Luebbe
Quoted 6 lines · Jan Luebbe

Using set_scl may be ineffective before calling the driver specific prepare_recovery callback, which might change into a test mode. So instead of setting SCL in i2c_generic_scl_recovery, move it to i2c_generic_recovery (after the optional prepare_recovery).

I've tested it with oscilloscope on Beagle Bone Black, makes sense with your next patch, so:

Quoted 27 lines
---
 drivers/i2c/i2c-core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/i2c/i2c-core.c +3 -1
index 069a41f116dd..be992b3e0be8 100644
@@ -567,6 +567,9 @@ static int i2c_generic_recovery(struct i2c_adapter *adap)
 	if (bri->prepare_recovery)
 		bri->prepare_recovery(adap);
 
+	bri->set_scl(adap, val);
+	ndelay(RECOVERY_NDELAY);
+
 	/*
 	 * By this time SCL is high, as we need to give 9 falling-rising edges
 	 */
@@ -597,7 +600,6 @@ static int i2c_generic_recovery(struct i2c_adapter *adap)
 
 int i2c_generic_scl_recovery(struct i2c_adapter *adap)
 {
-	adap->bus_recovery_info->set_scl(adap, 1);
 	return i2c_generic_recovery(adap);
 }
 EXPORT_SYMBOL_GPL(i2c_generic_scl_recovery);
Applied
#3 lore raw

PATCH 1/1 i2c: core: only use set_scl for bus recovery after calling prepare_recovery

In reply to Jan Luebbe
Quoted 6 lines · Jan Luebbe

Using set_scl may be ineffective before calling the driver specific prepare_recovery callback, which might change into a test mode. So instead of setting SCL in i2c_generic_scl_recovery, move it to i2c_generic_recovery (after the optional prepare_recovery).

Applied to for-current, thanks!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150731/77823461/attachment-0001.sig>