[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Zo_cW57i_GMlmYV-@pollux>
Date: Thu, 11 Jul 2024 15:21:31 +0200
From: Danilo Krummrich <dakr@...hat.com>
To: Viresh Kumar <viresh.kumar@...aro.org>
Cc: "Rafael J. Wysocki" <rafael@...nel.org>,
Miguel Ojeda <miguel.ojeda.sandonis@...il.com>,
Miguel Ojeda <ojeda@...nel.org>,
Alex Gaynor <alex.gaynor@...il.com>,
Wedson Almeida Filho <wedsonaf@...il.com>,
Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <benno.lossin@...ton.me>,
Andreas Hindborg <a.hindborg@...sung.com>,
Alice Ryhl <aliceryhl@...gle.com>, linux-pm@...r.kernel.org,
Vincent Guittot <vincent.guittot@...aro.org>,
Stephen Boyd <sboyd@...nel.org>, Nishanth Menon <nm@...com>,
rust-for-linux@...r.kernel.org,
Manos Pitsidianakis <manos.pitsidianakis@...aro.org>,
Erik Schilling <erik.schilling@...aro.org>,
Alex Bennée <alex.bennee@...aro.org>,
Joakim Bech <joakim.bech@...aro.org>, Rob Herring <robh@...nel.org>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH V4 8/8] cpufreq: Add Rust based cpufreq-dt driver
On Thu, Jul 11, 2024 at 06:38:02PM +0530, Viresh Kumar wrote:
> 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.
I guess you are referring to the case where you want to register a CPUfreq
driver directly from `Module::init`. I see two possible options for that, with
one of them being the preference.
(1) You simply provide an additional `Registration::new_foreign_owed` function.
(2) You require drivers to always implement a "dummy" struct platform_device,
there is platform_device_register_simple() for that purpose.
I think (2) is the preferred option.
>
> --
> viresh
>
> [1] https://lore.kernel.org/all/20240620100556.xsehtd7ii25rtn7k@vireshk-i7/
>
Powered by blists - more mailing lists