linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] counter: ti-eqep: balance pm_runtime on devm_clk_get_enabled() failure
@ 2026-05-25 15:21 Stepan Ionichev
  2026-05-26 10:32 ` Joshua Crofts
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Stepan Ionichev @ 2026-05-25 15:21 UTC (permalink / raw)
  To: wbg; +Cc: m32285159, dlechner, nuno.sa, andy, linux-iio, linux-kernel,
	sozdayvek

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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-05-29  9:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-25 15:21 [PATCH v2] counter: ti-eqep: balance pm_runtime on devm_clk_get_enabled() failure Stepan Ionichev
2026-05-26 10:32 ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).