Messages in this thread Patch in this message |  | | From | Danilo Krummrich <> | | Subject | [PATCH 10/24] rust: device: implement Sync for Device<Bound> | | Date | Tue, 28 Apr 2026 00:11:08 +0200 |
| |
The underlying `struct device` is the same for all device contexts; `Bound` is a zero-sized type-state marker that does not affect thread safety. Implement `Sync` for `Device<Bound>` with the same safety argument as the existing `Device<Normal>` implementation.
This is needed for types that hold `&'a Device<Bound>`, such as `io::mem::IoMem`, to be `Send`.
Signed-off-by: Danilo Krummrich <dakr@kernel.org> --- rust/kernel/device.rs | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/rust/kernel/device.rs b/rust/kernel/device.rs index 09cbe8a438a9..b330b87178d3 100644 --- a/rust/kernel/device.rs +++ b/rust/kernel/device.rs @@ -503,6 +503,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 -- 2.54.0
|  |