From: Danilo Krummrich Date: Mon, 25 May 2026 20:20:57 +0000 (+0200) Subject: rust: device: implement Sync for Device X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=de12e48a1be3e9edc0f8bc6e37bad8f7b6f32d54;p=thirdparty%2Fkernel%2Flinux.git rust: device: implement Sync for Device Implement Sync for Device in addition to Device. Device uses the same underlying struct device as Device; Bound is a zero-sized type-state marker that does not affect thread safety. This is needed for types that hold &'bound Device, such as io::mem::IoMem, to be 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-11-dakr@kernel.org Signed-off-by: Danilo Krummrich --- diff --git a/rust/kernel/device.rs b/rust/kernel/device.rs index 5df8fa108a522..c4486f4b8c403 100644 --- a/rust/kernel/device.rs +++ b/rust/kernel/device.rs @@ -467,6 +467,10 @@ unsafe impl Send for Device {} // synchronization in `struct device`. unsafe impl Sync for Device {} +// SAFETY: Same as `Device` -- the underlying `struct device` is the same; `Bound` is a +// zero-sized type-state marker that does not affect thread safety. +unsafe impl Sync for Device {} + /// Marker trait for the context or scope of a bus specific device. /// /// [`DeviceContext`] is a marker trait for types representing the context of a bus specific