From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Chen-Yu Tsai <wenst@chromium.org>
Cc: Matthias Brugger <matthias.bgg@gmail.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
Benson Leung <bleung@chromium.org>,
Tzung-Bi Shih <tzungbi@kernel.org>,
Dmitry Torokhov <dmitry.torokhov@gmail.com>,
Jiri Kosina <jikos@kernel.org>,
Andi Shyti <andi.shyti@kernel.org>,
linux-mediatek@lists.infradead.org, devicetree@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
chrome-platform@lists.linux.dev, linux-input@vger.kernel.org,
linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 1/9] regulator: core: Add "enable and wait" functions
Date: Tue, 21 Jul 2026 12:54:08 +0300 [thread overview]
Message-ID: <al9BwHbG5IX0mIem@ashevche-desk.local> (raw)
In-Reply-To: <20260721075226.2347933-2-wenst@chromium.org>
On Tue, Jul 21, 2026 at 03:52:15PM +0800, Chen-Yu Tsai wrote:
> In device power sequencing and initialization use cases, it is common
> for the driver to enable the regulator and then wait for a certain
> period of time to pass before continuing.
>
> In cases where the regulator supply is always on, or has been turned on
> or left on by another consumer, the driver could shorten the delay or
> skip it altogether, provided that enough time has already passed since
> the regulator was _actually_ turned on.
>
> Tracking this requires support from the regulator core. Introduce a
> "last turned on" timestamp field to the regulator device, and "enable
> and wait" functions to the single and bulk regulator consumer APIs.
> The existing "enable without wait" functions are then converted to
> macros that expand to the new functions.
>
> One case in particular is not optimized yet: a regulator left on either
> by hardware reset default or by the bootloader, but does not have the
> "regulator-boot-on" property set. As the enable timestamp only gets
> updated when enabled by a consumer or by the core, the first enablement
> always needs to wait.
...
> -/* locks held by regulator_enable() */
> -static int _regulator_enable(struct regulator *regulator)
> +/* locks held by regulator_enable_and_wait() */
> +static int _regulator_enable_and_wait(struct regulator *regulator, unsigned int wait_us)
Hmm...
This comment a bit confusing, perhaps adding some lockdep annotations help?
...
> + if (wait_us) {
> + ktime_t end = ktime_add_us(rdev->last_on, wait_us);
> + s64 remaining = ktime_us_delta(end, ktime_get_boottime());
> +
> + if (remaining > 0)
> + fsleep(remaining);
This style is discouraged as it makes maintenance harder. Better
s64 remaining;
remaining = ktime_us_delta(end, ktime_get_boottime());
if (remaining > 0)
fsleep(remaining);
> + }
...
> /* private: Internal use */
> int ret;
> + unsigned int wait_us;
If you want to make it more private (the above is only for kernel-doc) add
__private annotation that will affect how sparse will check this.
...
> -int __must_check regulator_enable(struct regulator *regulator);
> +int __must_check regulator_enable_and_wait(struct regulator *regulator, unsigned int ms);
ms or us? Please, double check all units.
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2026-07-21 9:54 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-21 7:52 [PATCH v3 0/9] arm64: mediatek: Chromebook trackpad supply fixes Chen-Yu Tsai
2026-07-21 7:52 ` [PATCH v3 1/9] regulator: core: Add "enable and wait" functions Chen-Yu Tsai
2026-07-21 8:08 ` sashiko-bot
2026-07-21 8:22 ` Chen-Yu Tsai
2026-07-21 9:54 ` Andy Shevchenko [this message]
2026-07-21 7:52 ` [PATCH v3 2/9] Input: elan_i2c - sort include statements Chen-Yu Tsai
2026-07-21 10:20 ` Andy Shevchenko
2026-07-21 7:52 ` [PATCH v3 3/9] Input: elan_i2c - Wait for initialization after enabling regulator supply Chen-Yu Tsai
2026-07-21 8:07 ` sashiko-bot
2026-07-21 7:52 ` [PATCH v3 4/9] HID: i2c-hid-of: skip post-power-on delay if powered on sufficiently long Chen-Yu Tsai
2026-07-21 8:06 ` sashiko-bot
2026-07-21 7:52 ` [PATCH v3 5/9] i2c: of-prober: " Chen-Yu Tsai
2026-07-21 7:52 ` [PATCH v3 6/9] i2c: of-prober: Defer regulator_disable() on successful probe in simple helper Chen-Yu Tsai
2026-07-21 8:06 ` sashiko-bot
2026-07-21 10:24 ` Andy Shevchenko
2026-07-22 8:34 ` Chen-Yu Tsai
2026-07-21 7:52 ` [PATCH v3 7/9] platform/chrome: of_hw_prober: Add delay for hana trackpads Chen-Yu Tsai
2026-07-21 10:27 ` Andy Shevchenko
2026-07-22 3:33 ` Chen-Yu Tsai
2026-07-21 7:52 ` [PATCH v3 8/9] arm64: dts: mediatek: mt8173-elm-hana: Unmark trackpad supply as always-on Chen-Yu Tsai
2026-07-21 7:52 ` [PATCH v3 9/9] arm64: dts: mediatek: mt8192-asurada-spherion: Add Synaptics trackpad's supply Chen-Yu Tsai
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=al9BwHbG5IX0mIem@ashevche-desk.local \
--to=andriy.shevchenko@linux.intel.com \
--cc=andi.shyti@kernel.org \
--cc=angelogioacchino.delregno@collabora.com \
--cc=bleung@chromium.org \
--cc=chrome-platform@lists.linux.dev \
--cc=devicetree@vger.kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=jikos@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=tzungbi@kernel.org \
--cc=wenst@chromium.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