Re: [PATCH v2 1/2] rust: introduce abstractions for fwctlg

Jason Gunthorpe
2026-01-28T15:56:51Z

On Wed, Jan 28, 2026 at 04:49:07PM +0100, Danilo Krummrich wrote:

> // Initialize the `data` initializer within the memory pointed
> // to by `raw_data`.
> unsafe { data.__pinned_init(raw_data) }.inspect_err(|_| {

> So, essentially the driver passes an initializer of its private data and we
> "write" this initializer into the extra memory allocated with
> _fwctl_alloc_device().

This all seems like the right way to do it!

My only remark it that it still doesn't give an opportunity to call a
function between init and register.

__pinned_init() is taking the T type without access to the initialized
fwctl_device

So if I add some function drivers need to call between init and register:

fwctl_XYZ(fwctl, ..)

It is not possible?

Or would you some container_of in rust within pinned_init()?

Or is it needed to add the typestate?

Jason