summaryrefslogtreecommitdiffstats
path: root/rust/kernel/platform.rs
diff options
context:
space:
mode:
authorDanilo Krummrich <dakr@kernel.org>2025-03-18 22:29:22 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-03-18 16:55:12 -0700
commit455943aa187fd93358ccd00c894934061153ec0c (patch)
treee4ab96c9cbe2651ba8fbc940d23bdb01531a83e8 /rust/kernel/platform.rs
parente2942bb4e62938fcef1481c9c1470b661087cdb7 (diff)
downloadlinux-455943aa187fd93358ccd00c894934061153ec0c.tar.gz
linux-455943aa187fd93358ccd00c894934061153ec0c.tar.bz2
linux-455943aa187fd93358ccd00c894934061153ec0c.zip
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 <dakr@kernel.org> Link: https://lore.kernel.org/r/20250318212940.137577-2-dakr@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'rust/kernel/platform.rs')
-rw-r--r--rust/kernel/platform.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/rust/kernel/platform.rs b/rust/kernel/platform.rs
index c77c9f2e9aea..2811ca53d8b6 100644
--- a/rust/kernel/platform.rs
+++ b/rust/kernel/platform.rs
@@ -233,3 +233,10 @@ impl AsRef<device::Device> 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<Normal>) are thread safe.
+unsafe impl Sync for Device {}