Re: [PATCH 1/2] rust: auxiliary: add registration data to auxiliary devices
From: Danilo Krummrich
Date: Thu Apr 30 2026 - 12:13:32 EST
On Thu Apr 30, 2026 at 5:08 PM CEST, Gary Guo wrote:
> I wonder if we could require auxillary drivers to specify a type, and then the
> abstraction would check if the type matches; if it matches, it create a
> `&Device<Core, T>` and `probe`, otherwise it skips over the driver completely.
The choice not to type auxiliary::Device over the registration data is
intentional.
The registration data is not intended for the child driver to use, but for the
parent driver to retrieve when the child passes its device back to the parent.
By typing the Device over the parent's registration data we force the parent
driver to expose its registration data to the child driver.
>> + /// Returns a pinned reference to the registration data set by the registering (parent) driver.
>> + ///
>> + /// Returns [`EINVAL`] if `T` does not match the type used by the parent driver when calling
>> + /// [`Registration::new()`].
>> + ///
>> + /// Returns [`ENOENT`] if no registration data has been set, e.g. when the device was
>> + /// registered by a C driver.
>> + pub fn registration_data<T: 'static>(&self) -> Result<Pin<&T>> {
>
> Any reason that this is not just `Result<&T>`?
Mainly consistency with other APIs, but I'm not really opinionated about it.