Re: [PATCH v4 2/9] rust/kernel: Add faux device bindings

Greg Kroah-Hartman
2025-02-11T05:53:17Z

On Mon, Feb 10, 2025 at 04:32:15PM +0000, Benno Lossin wrote:
> On 10.02.25 13:30, Greg Kroah-Hartman wrote:
> > From: Lyude Paul <lyude@redhat.com>
> >
> > This introduces a module for working with faux devices in rust, along with
> > adding sample code to show how the API is used. Unlike other types of
> > devices, we don't provide any hooks for device probe/removal - since these
> > are optional for the faux API and are unnecessary in rust.
>
> For me it would be useful to know why this is the case. I looked at the
> dummy regulator driver and it still has a `probe` function. Presumably,
> because it has to wait until other resources are usable and that is the
> case once `probe` gets called. But doesn't the same hold for Rust? Or
> are Rust modules loaded later than C modules? Because if I were to
> rewrite the regulator driver in Rust (assuming we had the abstractions),
> the `probe` code would be put into the `Module::init` function, right?
> Or am I missing something?

I left the probe() in the dummy driver to keep the same pattern of the
existing code, but there is no real requirement that it has that at all.
I could have rewritten the dummy driver to not need it, and maybe, after
time, we realize that no one needs the probe/remove function and then we
can remove it then.

thanks,

greg k-h