mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Arnav Kapoor <kapoorarnav43@gmail.com>
To: akshatrawat095@gmail.com
Cc: Arnav Kapoor <kapoorarnav43@gmail.com>,
	Jonathan Cameron <jic23@kernel.org>,
	David Lechner <dlechner@baylibre.com>,
	Nuno Sa <nuno.sa@analog.com>, Andy Shevchenko <andy@kernel.org>,
	Heiko Stuebner <heiko@sntech.de>,
	linux-iio@vger.kernel.org, linux-rockchip@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iio: adc: rockchip_saradc: disable vref on resume failure
Date: Sat,  5 Dec 2026 01:58:07 +0530	[thread overview]
Message-ID: <20261204202812.1049983-1-kapoorarnav43@gmail.com> (raw)
In-Reply-To: <20261204111238.425-1-akshatrawat095@gmail.com>

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).

      reply	other threads:[~2026-12-04 20:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04 11:12 Akshat Rawat
2026-12-04 20:28 ` Arnav Kapoor [this message]

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=20261204202812.1049983-1-kapoorarnav43@gmail.com \
    --to=kapoorarnav43@gmail.com \
    --cc=akshatrawat095@gmail.com \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=heiko@sntech.de \
    --cc=jic23@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=nuno.sa@analog.com \
    /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®