diff mbox series

[v2] i2c: imx: check bus for busy before signaling start condition.

Message ID 20181116195651.GA25822@server.chicago.weaver.network
State Superseded
Headers show
Series [v2] i2c: imx: check bus for busy before signaling start condition. | expand

Commit Message

Steven Weaver Nov. 16, 2018, 7:56 p.m. UTC
Setting MSTA in I2CR signals a start condition on the bus. In a
multi-master scenario, this could clobber a transaction already in
progress.

Signed-off-by: Steven Weaver <steve@weaverpad.net>
---
 drivers/i2c/busses/i2c-imx.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index c406700789e1..4720db608489 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -536,6 +536,9 @@  static int i2c_imx_start(struct imx_i2c_struct *i2c_imx)
 	usleep_range(50, 150);
 
 	/* Start I2C transaction */
+	result = i2c_imx_bus_busy(i2c_imx, 1);
+	if (result)
+		return result;
 	temp = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2CR);
 	temp |= I2CR_MSTA;
 	imx_i2c_write_reg(temp, i2c_imx, IMX_I2C_I2CR);