From: Cong Nguyen <congnt264@gmail.com>
To: Andi Shyti <andi.shyti@kernel.org>
Cc: Wolfram Sang <wsa@kernel.org>, Ed Blake <ed.blake@sondrel.com>,
linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] i2c: img-scb: disable the clocks when probe fails after init
Date: Thu, 26 Nov 2026 21:05:22 +0700 [thread overview]
Message-ID: <20261126140522.3991135-1-congnt264@gmail.com> (raw)
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
reply other threads:[~2026-11-26 14:05 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261126140522.3991135-1-congnt264@gmail.com \
--to=congnt264@gmail.com \
--cc=andi.shyti@kernel.org \
--cc=ed.blake@sondrel.com \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=wsa@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®