Re: [PATCH v3] rust: regulator: add a bare minimum regulator abstraction
From: Mark Brown
Date: Mon May 19 2025 - 07:47:02 EST
On Mon, May 19, 2025 at 01:25:56PM +0200, Benno Lossin wrote:
> On Mon May 19, 2025 at 11:56 AM CEST, Mark Brown wrote:
> > 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).
> What stops the last `regulator_put` to also call `regulator_disable` a
> correct number of times?
We obviously could but the regulator API defaults to not doing anything
unless explicitly told to since getting things wrong can physically
damage the system. We've no idea if just disabling the regulator would
be safe at this point so we just don't touch anything and complain about
it.
> What are the kinds of problems that one could encounter when not calling
> `regulator_disable` before `regulator_put` or if `regulator_enable` was
> never called to begin with?
If you don't disable the regulator you've just leaked a reference which
is obviously a problem.
Attachment:
signature.asc
Description: PGP signature