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

Message ID 20181116200456.GA26105@server.chicago.weaver.network
State New
Headers show
Series
  • [v3] i2c: imx: check bus for busy before signaling start condition.
Related show

Commit Message

Steven Weaver Nov. 16, 2018, 8:05 p.m.
Setting MSTA in I2CR signals a start condition on the
bus. In a multi-master scenario, this can 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(+)

Patch

diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index c406700789e1..8691b7fd6980 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, 0);
+	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);