Skip to content

Commit e2942bb

Browse files
Danilo Krummrichgregkh
authored andcommitted
rust: pci: impl Send + Sync for pci::Device
Commit 7b948a2 ("rust: pci: fix unrestricted &mut pci::Device") changed the definition of pci::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 4d320e3 commit e2942bb

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

rust/kernel/pci.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,3 +465,10 @@ impl AsRef<device::Device> for Device {
465465
unsafe { device::Device::as_ref(dev) }
466466
}
467467
}
468+
469+
// SAFETY: A `Device` is always reference-counted and can be released from any thread.
470+
unsafe impl Send for Device {}
471+
472+
// SAFETY: `Device` can be shared among threads because all methods of `Device`
473+
// (i.e. `Device<Normal>) are thread safe.
474+
unsafe impl Sync for Device {}

0 commit comments

Comments
 (0)