* [PATCH] i2c: ocores: Disable clock on failed resume
@ 2026-08-13 15:31 Ruoyu Wang
2026-08-13 21:34 ` Max Filippov
2026-08-14 21:47 ` Andi Shyti
0 siblings, 2 replies; 3+ messages in thread
From: Ruoyu Wang @ 2026-08-13 15:31 UTC (permalink / raw)
To: linux-i2c
Cc: peter, andrew, andi.shyti, jcmvbkbc, wsa, linux-kernel,
Ruoyu Wang
ocores_i2c_resume() enables the controller clock before reinitializing
the hardware. If the clock rate changed while the device was suspended,
ocores_init() may reject the resulting prescaler. The callback then
returns an error with the clock still enabled, while the controller
itself remains disabled.
Disable and unprepare the clock when ocores_init() fails so the failed
resume path balances the successful clk_prepare_enable() call.
This issue was found by a static analysis checker and confirmed by manual
source review.
Fixes: e961a094afe0 ("i2c: ocores: add common clock support")
Signed-off-by: Ruoyu Wang <ruoyuw560@gmail.com>
---
drivers/i2c/busses/i2c-ocores.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/i2c/busses/i2c-ocores.c b/drivers/i2c/busses/i2c-ocores.c
index df6ebf32d6e8f3..2d18c10358375f 100644
--- a/drivers/i2c/busses/i2c-ocores.c
+++ b/drivers/i2c/busses/i2c-ocores.c
@@ -755,7 +755,11 @@ static int ocores_i2c_resume(struct device *dev)
rate = clk_get_rate(i2c->clk) / 1000;
if (rate)
i2c->ip_clock_khz = rate;
- return ocores_init(dev, i2c);
+ ret = ocores_init(dev, i2c);
+ if (ret)
+ clk_disable_unprepare(i2c->clk);
+
+ return ret;
}
static DEFINE_NOIRQ_DEV_PM_OPS(ocores_i2c_pm,
--
2.51.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] i2c: ocores: Disable clock on failed resume
2026-08-13 15:31 [PATCH] i2c: ocores: Disable clock on failed resume Ruoyu Wang
@ 2026-08-13 21:34 ` Max Filippov
2026-08-14 21:47 ` Andi Shyti
1 sibling, 0 replies; 3+ messages in thread
From: Max Filippov @ 2026-08-13 21:34 UTC (permalink / raw)
To: Ruoyu Wang; +Cc: linux-i2c, peter, andrew, andi.shyti, wsa, linux-kernel
On Thu, Aug 13, 2026 at 8:32 AM Ruoyu Wang <ruoyuw560@gmail.com> wrote:
>
> ocores_i2c_resume() enables the controller clock before reinitializing
> the hardware. If the clock rate changed while the device was suspended,
> ocores_init() may reject the resulting prescaler. The callback then
> returns an error with the clock still enabled, while the controller
> itself remains disabled.
>
> Disable and unprepare the clock when ocores_init() fails so the failed
> resume path balances the successful clk_prepare_enable() call.
>
> This issue was found by a static analysis checker and confirmed by manual
> source review.
>
> Fixes: e961a094afe0 ("i2c: ocores: add common clock support")
> Signed-off-by: Ruoyu Wang <ruoyuw560@gmail.com>
> ---
> drivers/i2c/busses/i2c-ocores.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
Reviewed-by: Max Filippov <jcmvbkbc@gmail.com>
--
Thanks.
-- Max
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] i2c: ocores: Disable clock on failed resume
2026-08-13 15:31 [PATCH] i2c: ocores: Disable clock on failed resume Ruoyu Wang
2026-08-13 21:34 ` Max Filippov
@ 2026-08-14 21:47 ` Andi Shyti
1 sibling, 0 replies; 3+ messages in thread
From: Andi Shyti @ 2026-08-14 21:47 UTC (permalink / raw)
To: Ruoyu Wang; +Cc: linux-i2c, peter, andrew, jcmvbkbc, wsa, linux-kernel
Hi Ruoyu,
On Thu, Aug 13, 2026 at 11:31:55PM +0800, Ruoyu Wang wrote:
> ocores_i2c_resume() enables the controller clock before reinitializing
> the hardware. If the clock rate changed while the device was suspended,
> ocores_init() may reject the resulting prescaler. The callback then
> returns an error with the clock still enabled, while the controller
> itself remains disabled.
>
> Disable and unprepare the clock when ocores_init() fails so the failed
> resume path balances the successful clk_prepare_enable() call.
>
> This issue was found by a static analysis checker and confirmed by manual
> source review.
>
> Fixes: e961a094afe0 ("i2c: ocores: add common clock support")
> Signed-off-by: Ruoyu Wang <ruoyuw560@gmail.com>
merged to i2c/i2c-2.
Thanks,
Andi
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-08-14 21:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-13 15:31 [PATCH] i2c: ocores: Disable clock on failed resume Ruoyu Wang
2026-08-13 21:34 ` Max Filippov
2026-08-14 21:47 ` Andi Shyti
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox