Re: [PATCH] iio: adc: rockchip_saradc: disable vref on resume failure
From: Arnav Kapoor
Date: Fri Dec 04 2026 - 15:28:26 EST
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).