Re: [PATCH v2 2/3] rust: auxiliary: add registration data to auxiliary devices

Alice Ryhl
2026-05-06T12:42:30Z

On Tue, May 05, 2026 at 05:23:08PM +0200, Danilo Krummrich wrote:
> Add a registration_data pointer to struct auxiliary_device, allowing the
> registering (parent) driver to attach private data to the device at
> registration time and retrieve it later when called back by the
> auxiliary (child) driver.
>
> By tying the data to the device's registration, Rust drivers can bind
> the lifetime of device resources to it, since the auxiliary bus
> guarantees that the parent driver remains bound while the auxiliary
> device is bound.
>
> On the Rust side, Registration<T> takes ownership of the data via
> ForeignOwnable. A TypeId is stored alongside the data for runtime type
> checking, making Device::registration_data<T>() a safe method.
>
> Signed-off-by: Danilo Krummrich <dakr@kernel.org>

The change itself LGTM.

Reviewed-by: Alice Ryhl <aliceryhl@google.com>

But I'm not entirely convinced that this is the most convenient
user-interface. I'm wondering if the auxiliary driver trait could
specify which type the parent driver data is using in an associated
type, and whether you could eliminate the check and error path that way.
But then again, AuxiliaryDriver does not appear as a generic parameter
in auxiliary::Driver, so it might not work.

Alice