Re: [PATCH 2/2] rust/kernel: Add platform::ModuleDevice
From: Danilo Krummrich
Date: Fri Jan 24 2025 - 06:03:03 EST
On Thu, Jan 23, 2025 at 07:33:28PM -0500, Lyude Paul wrote:
> On Thu, 2025-01-23 at 07:23 +0100, Greg Kroah-Hartman wrote:
> > On Wed, Jan 22, 2025 at 06:49:22PM -0500, Lyude Paul wrote:
> >
> > And modules are code, not data. Let's not start to even attempt to tie
> > lifetimes of device structures to module code, that way lies madness and
> > rolls back the work we did decades ago to split the two apart :)
>
> To make sure I'm understanding you properly, by "are code not data" you're
> suggesting that resources (devices, driver registrations, etc.) should have
> their lifetime entirely managed by the kernel and not as part of the module
> data structure correct?
I think that's two different things.
Driver registrations are bound to the module lifetime and in Rust, where we have
a structure that represents the module lifetime, driver registrations are part
of the module structure. That's fine.
Device are more of a concern here, since they ideally orginate from real
hardware and hence shouldn't be bound to a module lifetime.
I think a virtual device would need to be an exception though. What else, if not
the module should define its lifetime?