From 70e453c2c4e1b85c5025aa0419dd066fc0fecb09 Mon Sep 17 00:00:00 2001 From: Jukka Laitinen Date: Tue, 22 Sep 2026 12:04:59 +0300 Subject: [PATCH] [UPSTREAM] arch/arm/imxrt: Improve imxrt_lpi2c_reset Re-initialize the bus even in the case the bus cannot be re-covered. The client still has a reference to the bus, and may try to access it again. If the bus is not initialized or the root clock is off, the access may cause a crash. Signed-off-by: Jukka Laitinen --- arch/arm/src/imxrt/imxrt_lpi2c.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/arm/src/imxrt/imxrt_lpi2c.c b/arch/arm/src/imxrt/imxrt_lpi2c.c index ce57103b962..7953de8557f 100644 --- a/arch/arm/src/imxrt/imxrt_lpi2c.c +++ b/arch/arm/src/imxrt/imxrt_lpi2c.c @@ -2387,6 +2387,10 @@ static int imxrt_lpi2c_reset(struct i2c_master_s *dev) imxrt_config_gpio(sda_gpio); imxrt_config_gpio(scl_gpio); + ret = OK; + +out: + /* Re-init the port */ imxrt_lpi2c_init(priv); @@ -2394,9 +2398,6 @@ static int imxrt_lpi2c_reset(struct i2c_master_s *dev) /* Restore the frequency */ imxrt_lpi2c_setclock(priv, frequency); - ret = OK; - -out: /* Release the port for reuse by other clients */