lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <DA16TWRBVV1B.2IT3D3ROHA3MI@kernel.org>
Date: Tue, 20 May 2025 20:09:24 +0200
From: "Benno Lossin" <lossin@...nel.org>
To: "Alexandre Courbot" <acourbot@...dia.com>, "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 4:43 PM CEST, Alexandre Courbot wrote:
> 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.

Yeah, so I think it would be best if we changed to the typestate design.

---
Cheers,
Benno

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ