Messages in this thread Patch in this message |  | | From | Danilo Krummrich <> | | Subject | [PATCH 09/24] rust: usb: implement Sync for Device<Bound> | | Date | Tue, 28 Apr 2026 00:11:07 +0200 |
| |
Device<Bound> uses the same underlying struct usb_device as Device<Normal>; Bound is a zero-sized type-state marker that does not affect thread safety.
This is needed for drivers to store &'a usb::Device<Bound> in their HRT private data while remaining Send.
Signed-off-by: Danilo Krummrich <dakr@kernel.org> --- rust/kernel/usb.rs | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/rust/kernel/usb.rs b/rust/kernel/usb.rs index 9b9d3ae41087..442e456fd2d3 100644 --- a/rust/kernel/usb.rs +++ b/rust/kernel/usb.rs @@ -467,6 +467,10 @@ unsafe impl Send for Device {} // allow any mutation through a shared reference. unsafe impl Sync for Device {} +// SAFETY: Same as `Device<Normal>` -- the underlying `struct usb_device` is the same; +// `Bound` is a zero-sized type-state marker that does not affect thread safety. +unsafe impl Sync for Device<device::Bound> {} + /// Declares a kernel module that exposes a single USB driver. /// /// # Examples -- 2.54.0
|  |