From 2b42b3527ea03e894d33dc6d878c27e41f022588 Mon Sep 17 00:00:00 2001 From: David Wu Date: Fri, 22 Dec 2023 11:36:49 +0800 Subject: [PATCH] i2c: busses: rk3x: Sync with i2c->msg with idle state Ensure that the I2C->msg is synchronized with the idle state, and the I2C->msg may still be used in the stop phase, need to wait until the I2C transfer is completed, and then set I2C->msg to be null. Signed-off-by: David Wu Change-Id: I8a8e8c1e72f28cf4c95fe4efb559177056f483d1 --- drivers/i2c/busses/i2c-rk3x.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-rk3x.c b/drivers/i2c/busses/i2c-rk3x.c index 69a56bf99e42..4fe2e04f533f 100644 --- a/drivers/i2c/busses/i2c-rk3x.c +++ b/drivers/i2c/busses/i2c-rk3x.c @@ -387,7 +387,6 @@ static void rk3x_i2c_stop(struct rk3x_i2c *i2c, int error) unsigned int ctrl; i2c->processed = 0; - i2c->msg = NULL; i2c->error = error; if (i2c->is_last_msg) { @@ -404,6 +403,7 @@ static void rk3x_i2c_stop(struct rk3x_i2c *i2c, int error) /* Signal rk3x_i2c_xfer to start the next message. */ i2c->busy = false; i2c->state = STATE_IDLE; + i2c->msg = NULL; /* * The HW is actually not capable of REPEATED START. But we can @@ -572,7 +572,6 @@ static void rk3x_i2c_handle_stop(struct rk3x_i2c *i2c, unsigned int ipd) } i2c->processed = 0; - i2c->msg = NULL; } /* ack interrupt */ @@ -587,6 +586,7 @@ static void rk3x_i2c_handle_stop(struct rk3x_i2c *i2c, unsigned int ipd) i2c->busy = false; i2c->state = STATE_IDLE; + i2c->msg = NULL; /* signal rk3x_i2c_xfer that we are finished */ rk3x_i2c_wake_up(i2c);