From: Maud Spierings <maud_spierings@hotmail.com>
To: Mark Brown <broonie@kernel.org>,
Daniel Almeida <daniel.almeida@collabora.com>
Cc: "Miguel Ojeda" <ojeda@kernel.org>,
"Alex Gaynor" <alex.gaynor@gmail.com>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <benno.lossin@proton.me>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Danilo Krummrich" <dakr@kernel.org>,
"Boris Brezillon" <boris.brezillon@collabora.com>,
"Sebastian Reichel" <sebastian.reichel@collabora.com>,
lgirdwood@gmail.com, linux-kernel@vger.kernel.org,
rust-for-linux@vger.kernel.org
Subject: Re: [PATCH RESEND v2] rust: regulator: add a bare minimum regulator abstraction
Date: Thu, 27 Mar 2025 12:36:23 +0100 [thread overview]
Message-ID: <AM7P189MB1009748DBA1F99F2BBEC2292E3A12@AM7P189MB1009.EURP189.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <f22cbd85-1896-4842-8746-d74ee160ab3c@sirena.org.uk>
On 3/27/25 12:32, Mark Brown wrote:
> On Wed, Mar 26, 2025 at 04:49:26PM -0300, Daniel Almeida wrote:
>>> On 26 Mar 2025, at 15:56, Mark Brown <broonie@kernel.org> wrote:
>
>>>> + /// Disables the regulator.
>>>> + pub fn disable(self) -> Result<Regulator> {
>>>> + // Keep the count on `regulator_get()`.
>>>> + let regulator = ManuallyDrop::new(self);
>
>>> This looks like user code could manually call it which feels like asking
>>> for trouble?
>
>> Yes, user code can call this. My understanding is that drivers may want to
>> disable the regulator at runtime, possibly to save power when the device is
>> idle?
>
>> What trouble are you referring to?
>
> My understanding was that the enable was done by transforming a
> Regulator into an EnabledRegulator but if you can explicitly call
> disable() on an EnabledRegulator without destroying it then you've got
> an EnabledRegulator which isn't actually enabled. Perhaps it's not
> clear to me how the API should work?
From my understanding, disable() takes ownership of self, it does not
take a reference, so the EnabledRegulator is consumed and the Regulator
is returned through the result. So EnabledRegulator will get dropped in
this function which owns it.
next prev parent reply other threads:[~2025-03-27 11:36 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-26 18:39 Daniel Almeida
2025-03-26 18:56 ` Mark Brown
2025-03-26 19:49 ` Daniel Almeida
2025-03-27 11:32 ` Mark Brown
2025-03-27 11:36 ` Maud Spierings [this message]
2025-03-27 11:42 ` Mark Brown
2025-03-27 11:46 ` Daniel Almeida
2025-03-27 11:50 ` Danilo Krummrich
2025-03-27 12:06 ` Daniel Almeida
2025-03-27 13:46 ` Sebastian Reichel
2025-03-27 15:06 ` Mark Brown
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=AM7P189MB1009748DBA1F99F2BBEC2292E3A12@AM7P189MB1009.EURP189.PROD.OUTLOOK.COM \
--to=maud_spierings@hotmail.com \
--cc=a.hindborg@kernel.org \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=benno.lossin@proton.me \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=boris.brezillon@collabora.com \
--cc=broonie@kernel.org \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=gary@garyguo.net \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=sebastian.reichel@collabora.com \
--cc=tmgross@umich.edu \
/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®