diff mbox

[RFT] i2c: algos: bit: prepare/unprepare before sending initial STOP

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

Commit Message

Wolfram Sang June 15, 2018, 5:17 a.m. UTC
Some adapters need to be prepared/unprepared before bitbanging the bus.
Do this for the initial STOP, too.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---

Ok, another idea to fix the regression. I'm not 100% sure if the placement is
perfect, but it should serve well enough as a proof of concept to see if this
is the actual issue. It looks promising, though.

 drivers/i2c/algos/i2c-algo-bit.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Sergei Shtylyov June 15, 2018, 8:25 a.m. UTC | #1
On 6/15/2018 8:17 AM, Wolfram Sang wrote:

> Some adapters need to be prepared/unprepared before bitbanging the bus.

    Before/after?

> Do this for the initial STOP, too.
> 
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
[...]

MBR, Sergei
diff mbox

Patch

diff --git a/drivers/i2c/algos/i2c-algo-bit.c b/drivers/i2c/algos/i2c-algo-bit.c
index 4a34f311e1ff..fab4437ecbb5 100644
--- a/drivers/i2c/algos/i2c-algo-bit.c
+++ b/drivers/i2c/algos/i2c-algo-bit.c
@@ -648,10 +648,19 @@  static int __i2c_bit_add_bus(struct i2c_adapter *adap,
 		adap->quirks = &i2c_bit_quirk_no_clk_stretch;
 
 	/* Bring bus to a known state. Looks like STOP if bus is not free yet */
+	if (bit_adap->pre_xfer) {
+		ret = bit_adap->pre_xfer(adap);
+		if (ret < 0)
+			return ret;
+	}
+
 	setscl(bit_adap, 1);
 	udelay(bit_adap->udelay);
 	setsda(bit_adap, 1);
 
+	if (bit_adap->post_xfer)
+		bit_adap->post_xfer(adap);
+
 	ret = add_adapter(adap);
 	if (ret < 0)
 		return ret;