diff options
| author | Danilo Krummrich <dakr@kernel.org> | 2026-05-05 17:23:08 +0200 |
|---|---|---|
| committer | Danilo Krummrich <dakr@kernel.org> | 2026-05-11 15:26:12 +0200 |
| commit | fd3b87ff0232f46e1ad53a48609a3853c8757c6c (patch) | |
| tree | b808a8a7b0ef53891648e5ac0fef90b3db75d436 /include/linux | |
| parent | abb21500e7e5dcf2d1b1a4a02b2ee77b3d5061b6 (diff) | |
| download | lwn-fd3b87ff0232f46e1ad53a48609a3853c8757c6c.tar.gz lwn-fd3b87ff0232f46e1ad53a48609a3853c8757c6c.zip | |
rust: auxiliary: add registration data to auxiliary devices
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.
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Link: https://patch.msgid.link/20260505152400.3905096-3-dakr@kernel.org
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/auxiliary_bus.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/include/linux/auxiliary_bus.h b/include/linux/auxiliary_bus.h index bc09b55e3682..4e1ad8ccbcdd 100644 --- a/include/linux/auxiliary_bus.h +++ b/include/linux/auxiliary_bus.h @@ -62,6 +62,9 @@ * @sysfs.irqs: irqs xarray contains irq indices which are used by the device, * @sysfs.lock: Synchronize irq sysfs creation, * @sysfs.irq_dir_exists: whether "irqs" directory exists, + * @registration_data_rust: private data owned by the registering (parent) + * driver; valid for as long as the device is + * registered with the driver core, * * An auxiliary_device represents a part of its parent device's functionality. * It is given a name that, combined with the registering drivers @@ -148,6 +151,7 @@ struct auxiliary_device { struct mutex lock; /* Synchronize irq sysfs creation */ bool irq_dir_exists; } sysfs; + void *registration_data_rust; }; /** |
