* [PATCH] iio: adc: rockchip_saradc: disable vref on resume failure
@ 2026-12-04 11:12 Akshat Rawat
2026-12-04 20:28 ` Arnav Kapoor
0 siblings, 1 reply; 2+ messages in thread
From: Akshat Rawat @ 2026-12-04 11:12 UTC (permalink / raw)
To: Jonathan Cameron
Cc: David Lechner, Nuno Sa, Andy Shevchenko, Heiko Stuebner,
linux-iio, linux-rockchip, linux-arm-kernel, linux-kernel,
Akshat Rawat
In rockchip_saradc_resume(), info->vref is enabled before preparing and
enabling info->pclk and info->clk. If enabling either clock fails, the
error paths return without disabling info->vref, leaving its enable
count unbalanced.
Add an error unwind path to disable info->pclk (when enabling info->clk
fails) and info->vref, matching rockchip_saradc_suspend().
Fixes: 44d6f2ef94f9 ("iio: adc: add driver for Rockchip saradc")
Signed-off-by: Akshat Rawat <akshatrawat095@gmail.com>
---
Compile-tested (x86_64 gcc 15.2.0, W=1, CONFIG_WERROR=y) with
CONFIG_PM_SLEEP=y and CONFIG_PM=n; not tested on hardware.
drivers/iio/adc/rockchip_saradc.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/adc/rockchip_saradc.c b/drivers/iio/adc/rockchip_saradc.c
index 5c45fae11890..f2f901017359 100644
--- a/drivers/iio/adc/rockchip_saradc.c
+++ b/drivers/iio/adc/rockchip_saradc.c
@@ -613,12 +613,18 @@ static int rockchip_saradc_resume(struct device *dev)
ret = clk_prepare_enable(info->pclk);
if (ret)
- return ret;
+ goto err_disable_vref;
ret = clk_prepare_enable(info->clk);
if (ret)
- clk_disable_unprepare(info->pclk);
+ goto err_disable_pclk;
+
+ return 0;
+err_disable_pclk:
+ clk_disable_unprepare(info->pclk);
+err_disable_vref:
+ regulator_disable(info->vref);
return ret;
}
base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244
--
2.56.1.windows.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] iio: adc: rockchip_saradc: disable vref on resume failure
2026-12-04 11:12 [PATCH] iio: adc: rockchip_saradc: disable vref on resume failure Akshat Rawat
@ 2026-12-04 20:28 ` Arnav Kapoor
0 siblings, 0 replies; 2+ messages in thread
From: Arnav Kapoor @ 2026-12-04 20:28 UTC (permalink / raw)
To: akshatrawat095
Cc: Arnav Kapoor, Jonathan Cameron, David Lechner, Nuno Sa,
Andy Shevchenko, Heiko Stuebner, linux-iio, linux-rockchip,
linux-arm-kernel, linux-kernel
On Fri, Dec 04, 2026 at 11:12:37AM +0000, Akshat Rawat wrote:
> In rockchip_saradc_resume(), info->vref is enabled before preparing and
> enabling info->pclk and info->clk. If enabling either clock fails, the
> error paths return without disabling info->vref, leaving its enable
> count unbalanced.
I'm not sure the count is unbalanced today. probe() doesn't release
vref or the clocks in a remove() callback; it hands them to devm:
vref to devm_add_action_or_reset(rockchip_saradc_regulator_disable)
and the clocks to devm_clk_get_enabled(). So with the current code,
after a failed resume:
probe: vref enabled (1)
suspend: vref disabled (0)
resume: vref enabled (1), pclk fails, return
unbind (devm): regulator_disable() -> 0, balanced
With this patch the error path drops vref to 0, and the devm action
then disables it a second time on unbind, which the regulator core
warns about as an unbalanced disable. pclk already behaves like this
since 560c6b914c6e ("iio: adc: rockchip_saradc: fix missing
clk_disable_unprepare() on error in rockchip_saradc_resume"), which
predates the devm_clk_get_enabled() conversion. A following suspend
would likewise disable all three again.
So whether resume should unwind at all here seems to be a question of
what state the driver assumes after a failed resume. Jonathan, do you
have a preference? If unwinding is wanted, I think the commit message
should say that it trades the leftover enable for a double disable at
unbind (or the devm teardown would need to know resume failed).
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-12-04 20:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-04 11:12 [PATCH] iio: adc: rockchip_saradc: disable vref on resume failure Akshat Rawat
2026-12-04 20:28 ` Arnav Kapoor
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®