aboutsummaryrefslogtreecommitdiffstats
path: root/rust
diff options
authorDanilo Krummrich <dakr@kernel.org>2026-05-25 22:20:53 +0200
committerDanilo Krummrich <dakr@kernel.org>2026-05-27 16:22:41 +0200
commit0b9a29c3a4e2a1f0d0b73ad4c4a4175212bacf21 (patch)
tree92ed3c9d18d93f476e80a2ccd506186f17e5aacf /rust
parentbe31fcf5af751815457102575b816a2bd31b4562 (diff)
downloadlinux-next-history-0b9a29c3a4e2a1f0d0b73ad4c4a4175212bacf21.tar.gz
rust: pci: implement Sync for Device<Bound>
Implement Sync for Device<Bound> in addition to Device<Normal>. Device<Bound> uses the same underlying struct pci_dev as Device<Normal>; Bound is a zero-sized type-state marker that does not affect thread safety. This is needed for drivers to store &'bound pci::Device<Bound> in their private data while remaining Send. Reviewed-by: Alexandre Courbot <acourbot@nvidia.com> Reviewed-by: Gary Guo <gary@garyguo.net> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Acked-by: Uwe Kleine-König <ukleinek@kernel.org> Tested-by: Dirk Behme <dirk.behme@de.bosch.com> Link: https://patch.msgid.link/20260525202921.124698-7-dakr@kernel.org Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Diffstat (limited to 'rust')
-rw-r--r--rust/kernel/pci.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/rust/kernel/pci.rs b/rust/kernel/pci.rs
index c743f2abb62f5..d214a861375d7 100644
--- a/rust/kernel/pci.rs
+++ b/rust/kernel/pci.rs
@@ -528,3 +528,7 @@ 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 {}
+
+// SAFETY: Same as `Device<Normal>` -- the underlying `struct pci_dev` is the same;
+// `Bound` is a zero-sized type-state marker that does not affect thread safety.
+unsafe impl Sync for Device<device::Bound> {}