Re: [PATCH V11 13/15] rust: cpufreq: Extend abstractions for driver registration

From: Viresh Kumar
Date: Thu Apr 24 2025 - 02:02:09 EST


On 23-04-25, 14:05, Danilo Krummrich wrote:
> On 4/21/25 9:22 AM, Viresh Kumar wrote:
> > + /// Registers a CPU frequency driver with the cpufreq core.
> > + pub fn new() -> Result<Self> {
> > + // We can't use `&Self::VTABLE` directly because the cpufreq core modifies some fields in
> > + // the C `struct cpufreq_driver`, which requires a mutable reference.
> > + let mut drv = KBox::new(UnsafeCell::new(Self::VTABLE), GFP_KERNEL)?;
>
> Maybe add a comment that it would be desired to make a struct cpufreq_driver
> capable of being declared as static const in the future.

Is it really the case ? I am not sure if that's how the C code sees
these structures.

Most of the driver structures (platform, etc) contain `struct
device_driver`, which is mostly modified from the bus layer when the
driver is registered, and so it can't be a `const`. Apart from that
too, the drivers many sometimes carry flags.

File operations (with just callbacks) can be `const` though.

> Either way,
>
> Reviewed-by: Danilo Krummrich <dakr@xxxxxxxxxx>

Thanks a lot Danilo.

--
viresh