summaryrefslogtreecommitdiff
path: root/rust/kernel
diff options
context:
space:
mode:
authorDanilo Krummrich <dakr@kernel.org>2026-05-25 22:20:57 +0200
committerDanilo Krummrich <dakr@kernel.org>2026-05-27 16:22:41 +0200
commitde12e48a1be3e9edc0f8bc6e37bad8f7b6f32d54 (patch)
treec6c9bdec7bce1cd6198822a12753a6a0cc25942b /rust/kernel
parent3bb1655192aeed68b761891eabdc97d9f2f7fc38 (diff)
rust: device: implement Sync for Device<Bound>
Implement Sync for Device<Bound> in addition to Device<Normal>. Device<Bound> uses the same underlying struct device as Device<Normal>; Bound is a zero-sized type-state marker that does not affect thread safety. This is needed for types that hold &'bound Device<Bound>, such as io::mem::IoMem, to be Send. Reviewed-by: Alexandre Courbot <acourbot@nvidia.com> Reviewed-by: Gary Guo <gary@garyguo.net> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Acked-by: Uwe Kleine-König <ukleinek@kernel.org> Tested-by: Dirk Behme <dirk.behme@de.bosch.com> Link: https://patch.msgid.link/20260525202921.124698-11-dakr@kernel.org Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Diffstat (limited to 'rust/kernel')
-rw-r--r--rust/kernel/device.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/rust/kernel/device.rs b/rust/kernel/device.rs
index 5df8fa108a52..c4486f4b8c40 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<Normal>` -- 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<Bound> {}
+
/// 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