Re: [PATCH v3] rust: regulator: add a bare minimum regulator abstraction

From: Mark Brown
Date: Mon May 19 2025 - 06:00:12 EST


On Sun, May 18, 2025 at 04:04:24PM +0200, Benno Lossin wrote:

> I'm not sure if I understand correctly, so I'll just try to echo it and
> see if it's correct :)

> The `enable`/`disable` functions change a refcount on the underlying
> regulator that tracks if the regulator actually is enabled/disabled.
> Asking the hardware to enable or disable a regulator can fail, but if we
> already know that it is enabled, only the refcount is incremented.

Yes.

> It's okay to leak this enabled-refcount, since when the regulators
> actual refcount (so the one adjusted by `_get` & `_put`) hits zero, we
> can also disable the regulator. So the enabled-refcount is essentially a
> weak refcount that only does something while the regulator exists.

No. You should not leak any refcount, the per consumer refcount
duplicates what's being done for the regulator as a whole, one should
never be incremented or decremented without the other (but there may be
multiple consumers to choose from).

Attachment: signature.asc
Description: PGP signature