From: Stepan Ionichev <sozdayvek@gmail.com>
To: wbg@kernel.org
Cc: m32285159@gmail.com, dlechner@baylibre.com, nuno.sa@analog.com,
andy@kernel.org, linux-iio@vger.kernel.org,
linux-kernel@vger.kernel.org, sozdayvek@gmail.com
Subject: [PATCH v2] counter: ti-eqep: balance pm_runtime on devm_clk_get_enabled() failure
Date: Mon, 25 May 2026 20:21:37 +0500 [thread overview]
Message-ID: <20260525152137.7428-1-sozdayvek@gmail.com> (raw)
ti_eqep_probe() calls pm_runtime_enable() and pm_runtime_get_sync()
before devm_clk_get_enabled(). If the clk call fails, the function
returns directly via dev_err_probe(), leaving runtime PM enabled
and the usage counter incremented.
Route the clk error through the same err_pm cleanup as counter_add()
so the runtime PM state is unwound on every failure path.
Fixes: f213729f6796 ("counter: new TI eQEP driver")
Signed-off-by: Stepan Ionichev <sozdayvek@gmail.com>
---
v2:
- Collapse the dev_err_probe()+assignment pair into a single line
using its return value (Maxwell)
- Add Fixes tag
v1: https://lore.kernel.org/all/20260523184448.7609-1-sozdayvek@gmail.com/
drivers/counter/ti-eqep.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/drivers/counter/ti-eqep.c b/drivers/counter/ti-eqep.c
index d21c157e5..4f3b17939 100644
--- a/drivers/counter/ti-eqep.c
+++ b/drivers/counter/ti-eqep.c
@@ -548,17 +548,21 @@ static int ti_eqep_probe(struct platform_device *pdev)
pm_runtime_get_sync(dev);
clk = devm_clk_get_enabled(dev, NULL);
- if (IS_ERR(clk))
- return dev_err_probe(dev, PTR_ERR(clk), "failed to enable clock\n");
+ if (IS_ERR(clk)) {
+ err = dev_err_probe(dev, PTR_ERR(clk), "failed to enable clock\n");
+ goto err_pm;
+ }
err = counter_add(counter);
- if (err < 0) {
- pm_runtime_put_sync(dev);
- pm_runtime_disable(dev);
- return err;
- }
+ if (err < 0)
+ goto err_pm;
return 0;
+
+err_pm:
+ pm_runtime_put_sync(dev);
+ pm_runtime_disable(dev);
+ return err;
}
static void ti_eqep_remove(struct platform_device *pdev)
--
2.43.0
next reply other threads:[~2026-05-25 15:21 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-25 15:21 Stepan Ionichev [this message]
2026-05-26 10:32 ` [PATCH v2] counter: ti-eqep: balance pm_runtime on devm_clk_get_enabled() failure Joshua Crofts
2026-05-27 7:12 ` William Breathitt Gray
2026-05-27 8:10 ` Andy Shevchenko
2026-05-27 8:18 ` William Breathitt Gray
2026-05-27 8:29 ` Andy Shevchenko
2026-05-29 9:57 ` Stepan Ionichev
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=20260525152137.7428-1-sozdayvek@gmail.com \
--to=sozdayvek@gmail.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=m32285159@gmail.com \
--cc=nuno.sa@analog.com \
--cc=wbg@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