[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260128155646.GB1134360@nvidia.com>
Date: Wed, 28 Jan 2026 11:56:46 -0400
From: Jason Gunthorpe <jgg@...dia.com>
To: Danilo Krummrich <dakr@...nel.org>
Cc: Zhi Wang <zhiw@...dia.com>, rust-for-linux@...r.kernel.org,
linux-pci@...r.kernel.org, linux-kernel@...r.kernel.org,
aliceryhl@...gle.com, bhelgaas@...gle.com, kwilczynski@...nel.org,
ojeda@...nel.org, alex.gaynor@...il.com, boqun.feng@...il.com,
gary@...yguo.net, bjorn3_gh@...tonmail.com, lossin@...nel.org,
a.hindborg@...nel.org, tmgross@...ch.edu, markus.probst@...teo.de,
helgaas@...nel.org, cjia@...dia.com, smitra@...dia.com,
ankita@...dia.com, aniketa@...dia.com, kwankhede@...dia.com,
targupta@...dia.com, acourbot@...dia.com, joelagnelf@...dia.com,
jhubbard@...dia.com, zhiwang@...nel.org,
daniel.almeida@...labora.com
Subject: Re: [PATCH v2 1/2] rust: introduce abstractions for fwctlg
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
Powered by blists - more mailing lists