Skip to content

Commit

Permalink
rust: platform: impl Send + Sync for platform::Device
Browse files Browse the repository at this point in the history
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 <dakr@kernel.org>
Link: https://lore.kernel.org/r/20250318212940.137577-2-dakr@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Danilo Krummrich authored and Greg Kroah-Hartman committed Mar 18, 2025
1 parent e2942bb commit 455943a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions rust/kernel/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}

0 comments on commit 455943a

Please sign in to comment.