* [PATCH] i2c: img-scb: disable the clocks when probe fails after init
@ 2026-11-26 14:05 Cong Nguyen
0 siblings, 0 replies; only message in thread
From: Cong Nguyen @ 2026-11-26 14:05 UTC (permalink / raw)
To: Andi Shyti; +Cc: Wolfram Sang, Ed Blake, linux-i2c, linux-kernel
img_i2c_init() resumes the device and drops its reference with
pm_runtime_put_autosuspend(), so the device stays active with both
clocks on until the autosuspend timer fires.
If i2c_add_numbered_adapter() fails after that, the rpm_disable label
only suspends the device when runtime PM is not enabled, and
pm_runtime_disable() cancels the timer. The clocks stay enabled after
probe has failed.
Disable runtime PM first, then suspend the device if it is not already
suspended, as img_i2c_remove() does.
Fixes: 93222bd9b966 ("i2c: img-scb: Add runtime PM")
Signed-off-by: Cong Nguyen <congnt264@gmail.com>
---
drivers/i2c/busses/i2c-img-scb.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/i2c/busses/i2c-img-scb.c b/drivers/i2c/busses/i2c-img-scb.c
index 9d2ee449a40b..0fabc54ad572 100644
--- a/drivers/i2c/busses/i2c-img-scb.c
+++ b/drivers/i2c/busses/i2c-img-scb.c
@@ -1324,6 +1324,7 @@ static int img_i2c_probe(struct platform_device *pdev)
{
struct device_node *node = pdev->dev.of_node;
struct img_i2c *i2c;
+ bool rpm_enabled;
int irq, ret;
u32 val;
@@ -1400,9 +1401,10 @@ static int img_i2c_probe(struct platform_device *pdev)
return 0;
rpm_disable:
- if (!pm_runtime_enabled(&pdev->dev))
- img_i2c_runtime_suspend(&pdev->dev);
+ rpm_enabled = pm_runtime_enabled(&pdev->dev);
pm_runtime_disable(&pdev->dev);
+ if (!rpm_enabled || !pm_runtime_status_suspended(&pdev->dev))
+ img_i2c_runtime_suspend(&pdev->dev);
pm_runtime_dont_use_autosuspend(&pdev->dev);
return ret;
}
--
2.25.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-26 14:05 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-26 14:05 [PATCH] i2c: img-scb: disable the clocks when probe fails after init Cong Nguyen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®