From: Danilo Krummrich Date: Tue, 18 Mar 2025 21:29:22 +0000 (+0100) Subject: rust: platform: impl Send + Sync for platform::Device X-Git-Tag: v6.15-rc1~79^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=455943aa187fd93358ccd00c894934061153ec0c;p=thirdparty%2Fkernel%2Flinux.git rust: platform: impl Send + Sync for platform::Device Commit 4d320e30ee04 ("rust: platform: fix unrestricted &mut platform::Device") changed the definition of platform::Device and discarded the implicitly derived Send and Sync traits. This isn't required by upstream code yet, and hence did not cause any issues. However, it is relied on by upcoming drivers, hence add it back in. Signed-off-by: Danilo Krummrich Link: https://lore.kernel.org/r/20250318212940.137577-2-dakr@kernel.org Signed-off-by: Greg Kroah-Hartman --- diff --git a/rust/kernel/platform.rs b/rust/kernel/platform.rs index c77c9f2e9aea1..2811ca53d8b67 100644 --- a/rust/kernel/platform.rs +++ b/rust/kernel/platform.rs @@ -233,3 +233,10 @@ impl AsRef for Device { unsafe { device::Device::as_ref(dev) } } } + +// SAFETY: A `Device` is always reference-counted and can be released from any thread. +unsafe impl Send for Device {} + +// SAFETY: `Device` can be shared among threads because all methods of `Device` +// (i.e. `Device) are thread safe. +unsafe impl Sync for Device {}