From: Danilo Krummrich Date: Mon, 25 May 2026 20:20:56 +0000 (+0200) Subject: rust: usb: implement Sync for Device X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=3bb1655192aeed68b761891eabdc97d9f2f7fc38;p=thirdparty%2Flinux.git rust: usb: implement Sync for Device Implement Sync for Device in addition to Device. Device uses the same underlying struct usb_device as Device; Bound is a zero-sized type-state marker that does not affect thread safety. This is needed for drivers to store &'bound usb::Device in their private data while remaining Send. Reviewed-by: Alexandre Courbot Reviewed-by: Gary Guo Reviewed-by: Greg Kroah-Hartman Acked-by: Uwe Kleine-König Tested-by: Dirk Behme Link: https://patch.msgid.link/20260525202921.124698-10-dakr@kernel.org Signed-off-by: Danilo Krummrich --- diff --git a/rust/kernel/usb.rs b/rust/kernel/usb.rs index 88721970afcb7..6c917d8fa8839 100644 --- a/rust/kernel/usb.rs +++ b/rust/kernel/usb.rs @@ -468,6 +468,10 @@ unsafe impl Send for Device {} // allow any mutation through a shared reference. unsafe impl Sync for Device {} +// SAFETY: Same as `Device` -- 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 {} + /// Declares a kernel module that exposes a single USB driver. /// /// # Examples