[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <DA07TW3IGHW7.1QVLH8XUMWQ8Y@nvidia.com>
Date: Mon, 19 May 2025 23:43:44 +0900
From: "Alexandre Courbot" <acourbot@...dia.com>
To: "Benno Lossin" <lossin@...nel.org>, "Daniel Almeida"
<daniel.almeida@...labora.com>
Cc: "Miguel Ojeda" <ojeda@...nel.org>, "Alex Gaynor"
<alex.gaynor@...il.com>, "Boqun Feng" <boqun.feng@...il.com>, "Gary Guo"
<gary@...yguo.net>, Björn Roy Baron
<bjorn3_gh@...tonmail.com>, "Benno Lossin" <benno.lossin@...ton.me>,
"Andreas Hindborg" <a.hindborg@...nel.org>, "Alice Ryhl"
<aliceryhl@...gle.com>, "Trevor Gross" <tmgross@...ch.edu>, "Danilo
Krummrich" <dakr@...nel.org>, "Boris Brezillon"
<boris.brezillon@...labora.com>, "Sebastian Reichel"
<sebastian.reichel@...labora.com>, "Liam Girdwood" <lgirdwood@...il.com>,
"Mark Brown" <broonie@...nel.org>, <linux-kernel@...r.kernel.org>,
<rust-for-linux@...r.kernel.org>
Subject: Re: [PATCH v3] rust: regulator: add a bare minimum regulator
abstraction
On Mon May 19, 2025 at 8:54 PM JST, Benno Lossin wrote:
> On Mon May 19, 2025 at 12:52 PM CEST, Daniel Almeida wrote:
>>> I just mean the cases where users will want to enable and disable the
>>> regulator more frequently than just enabling it at probe time.
>>
>> This is already possible through kernel::types::Either.
>>
>> i.e.: the current design - or the proposed typestate one - can already switch
>> back and forth between Regulator and EnabledRegulator. Using Either makes it
>> just work, because you can change the variant at runtime without hassle. This
>> lets you consume self in an ergonomic way.
>
> Have you tried to write such a use-case using `Either`? My personal
> experience with `Either` was pretty horrible, since you always have to
> match on it before you can do anything to the values. It's not really
> ergonomic.
>
> I think we should remove it, as it also doesn't have any users at the
> moment. Anyone that needs it should define a custom enum for their
> use-case.
>
> And effectively an `Either<Regulator, EnabledRegulator>` is just a
> `Regulator<Switch>` in Alexandre's proposal if I understood it
> correctly.
Exactly. And btw, there is no reason to block the merging of a simple
version with just enabled and disabled types while we discuss the rest,
as long as it is implemented as a typestate. Adding more ways to control
the enabled status just involves adding new types to be given as
arguments to `Regulator<>` and their respective `impl` blocks, so it can
be done incrementally on top of that base, which I believe everybody
agrees is sound.
Powered by blists - more mailing lists