[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210727111554.1338832-2-codrin.ciubotariu@microchip.com>
Date: Tue, 27 Jul 2021 14:15:52 +0300
From: Codrin Ciubotariu <codrin.ciubotariu@...rochip.com>
To: <linux-i2c@...r.kernel.org>,
<linux-arm-kernel@...ts.infradead.org>,
<linux-kernel@...r.kernel.org>
CC: <nicolas.ferre@...rochip.com>, <alexandre.belloni@...tlin.com>,
<ludovic.desroches@...rochip.com>, <andrew@...people.com>,
<mhoffman@...htlink.com>, <khali@...ux-fr.org>, <wsa@...nel.org>,
"Codrin Ciubotariu" <codrin.ciubotariu@...rochip.com>
Subject: [PATCH 1/3] i2c: at91: move i2c_recover_bus() outside of at91_do_twi_transfer()
This patch doesn't add a functional change, it just separates the recovery
from the transfer itself.
Fixes: d3d3fdcc4c90 ("i2c: at91: implement i2c bus recovery")
Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@...rochip.com>
---
drivers/i2c/busses/i2c-at91-master.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/drivers/i2c/busses/i2c-at91-master.c b/drivers/i2c/busses/i2c-at91-master.c
index 1cceb6866689..0352dc09d697 100644
--- a/drivers/i2c/busses/i2c-at91-master.c
+++ b/drivers/i2c/busses/i2c-at91-master.c
@@ -639,13 +639,6 @@ static int at91_do_twi_transfer(struct at91_twi_dev *dev)
AT91_TWI_THRCLR | AT91_TWI_LOCKCLR);
}
- /*
- * some faulty I2C slave devices might hold SDA down;
- * we can send a bus clear command, hoping that the pins will be
- * released
- */
- i2c_recover_bus(&dev->adapter);
-
return ret;
}
@@ -705,7 +698,17 @@ static int at91_twi_xfer(struct i2c_adapter *adap, struct i2c_msg *msg, int num)
ret = at91_do_twi_transfer(dev);
- ret = (ret < 0) ? ret : num;
+ if (ret < 0) {
+ /*
+ * some faulty I2C slave devices might hold SDA down;
+ * we can send a bus clear command, hoping that the pins will be
+ * released
+ */
+ i2c_recover_bus(&dev->adapter);
+ } else {
+ ret = num;
+ }
+
out:
pm_runtime_mark_last_busy(dev->dev);
pm_runtime_put_autosuspend(dev->dev);
--
2.30.2
Powered by blists - more mailing lists