Skip to content

Commit 455943a

Browse files
Danilo Krummrichgregkh
authored andcommitted
rust: platform: impl Send + Sync for platform::Device
Commit 4d320e3 ("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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent e2942bb commit 455943a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

rust/kernel/platform.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,3 +233,10 @@ impl AsRef<device::Device> for Device {
233233
unsafe { device::Device::as_ref(dev) }
234234
}
235235
}
236+
237+
// SAFETY: A `Device` is always reference-counted and can be released from any thread.
238+
unsafe impl Send for Device {}
239+
240+
// SAFETY: `Device` can be shared among threads because all methods of `Device`
241+
// (i.e. `Device<Normal>) are thread safe.
242+
unsafe impl Sync for Device {}

0 commit comments

Comments
 (0)