Re: [PATCH v6 0/2] Add a bare-minimum Regulator abstraction
From: Daniel Almeida
Date: Tue Jul 01 2025 - 12:12:17 EST
> On 1 Jul 2025, at 12:34, Mark Brown <broonie@xxxxxxxxxx> wrote:
>
> On Tue, Jul 01, 2025 at 12:28:37PM -0300, Daniel Almeida wrote:
>
>> Is it ok for the abstraction to only be built when CONFIG_REGULATOR=y? This
>> means that any Rust drivers using it have to depend on CONFIG_REGULATOR too.
>
>> I thought this was acceptable, but apparently that is not the case? See this
>> comment from Rob Herring [0].
>
> The regulator API stubs itself out when disabled, but given that this is
> just wrappers it's not clear what the tasteful thing would be here - it
> should do the right thing because it will itself be built in terms of
> the C stubs. I don't know if Rust can sensibly stub things, or if
> there's much percentage in that for a thin wrapper which does basically
> nothing itself.
Well, if all functions in the regulator API have stubs, then perhaps a trivial
solution would be removing this #[cfg] from here:
+#[cfg(CONFIG_REGULATOR)] <---
+pub mod regulator;
This would build the abstractions unconditionally, and it would transparently
use the C stubs when calling the C functions.
Waiting for more comments from the other RFL folks.
-- Daniel