Re: [PATCH v2 3/4] rust: auxiliary: add auxiliary registration
From: Danilo Krummrich
Date: Mon Mar 17 2025 - 16:55:57 EST
On Mon, Mar 17, 2025 at 09:42:51PM +0100, Benoît du Garreau wrote:
> On Thu, 13 Mar 2025 03:23:52 +0100 Danilo Krummrich <dakr@xxxxxxxxxx> wrote:
>
> > +impl Registration {
> > + /// Create and register a new auxiliary device.
> > + pub fn new(parent: &device::Device, name: &CStr, id: u32, modname: &CStr) -> Result<Self> {
> > + let boxed = KBox::new(Opaque::<bindings::auxiliary_device>::zeroed(), GFP_KERNEL)?;
>
> You can use `KBox::init(kernel::init::zeroed(), GFP_KERNEL)` here. It avoids
> the need for the first patch.
You're right, that works indeed, the full call looks like this.
let boxed = KBox::init(kernel::init::zeroed::<Opaque::<bindings::auxiliary_device>>(), GFP_KERNEL)?;
However, I think Opaque::zeroed() reads a bit better. Unless anything speaks
against adding it, I think I prefer it as it is.