Re: [PATCH V4 8/8] cpufreq: Add Rust based cpufreq-dt driver

From: Viresh Kumar
Date: Thu Jul 11 2024 - 09:14:39 EST


On 11-07-24, 12:43, Danilo Krummrich wrote:
> Please just call this function `cpufreq::Registration::new`.
>
> The existance of a `cpufreq::Registration` means that it's registered. Once it
> is dropped, it's unregistered. It's the whole point of a `Registration` type
> to bind the period of a driver being registered to the lifetime of a
> `Registration` instance.
>
> Having `Registration::register` implies a bit, that we could ever have an
> unregistered `Registration`, which can never happen.
>
> Besides that, it'd be nice to follow the same naming scheme everywhere.

Sure, ::new() looks fine.

> > + c_str!("cpufreq-dt"),
> > + (),
> > + cpufreq::flags::NEED_INITIAL_FREQ_CHECK | cpufreq::flags::IS_COOLING_DEV,
> > + true,
> > + )?;
> > +
> > + Devres::new_foreign_owned(dev.as_ref(), drv, GFP_KERNEL)?;
>
> This should be called by `cpufreq::Registration` directly, otherwise it's every
> driver's responsibility to take care of the registration lifetime.

Some details were shared in another thread [1] earlier and I understand that
they are not very clear otherwise.

The problem is that it is not guaranteed that a struct device will be available
to the cpufreq core all the time, to which a platform driver (or other bus) can
be bound. And so this has to be taken care of by the individual drivers only.

--
viresh

[1] https://lore.kernel.org/all/20240620100556.xsehtd7ii25rtn7k@vireshk-i7/