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

From: Mark Brown
Date: Mon Jun 16 2025 - 10:07:03 EST


On Sun, Jun 15, 2025 at 10:31:59PM +0900, Alexandre Courbot wrote:
> On Tue Jun 10, 2025 at 12:32 AM JST, Daniel Almeida wrote:

> > +impl<T: RegulatorState + 'static> Drop for Regulator<T> {
> > + fn drop(&mut self) {
> > + if core::any::TypeId::of::<T>() == core::any::TypeId::of::<Enabled>() {
> > + // SAFETY: By the type invariants, we know that `self` owns a
> > + // reference on the enabled refcount, so it is safe to relinquish it
> > + // now.
> > + unsafe { bindings::regulator_disable(self.inner.as_ptr()) };
> > + }

> Do we want to keep enabled dynamic regulators enabled? IIUC that's what
> the C API does, so doing the same is ok, but let's at least mention that
> fact in the documentation.

I'm not sure what you mean by a "dynamic regulator" here but as
previously outlined we currently take a very conservative approach and
don't do things without being explicitly told to do so since getting
things wrong can result in physical damage to the system.

Please delete unneeded context from mails when replying. Doing this
makes it much easier to find your reply in the message, helping ensure
it won't be missed by people scrolling through the irrelevant quoted
material.

Attachment: signature.asc
Description: PGP signature