From: Danilo Krummrich Date: Mon, 25 May 2026 20:20:53 +0000 (+0200) Subject: rust: pci: implement Sync for Device X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0b9a29c3a4e2a1f0d0b73ad4c4a4175212bacf21;p=thirdparty%2Fkernel%2Flinux.git rust: pci: implement Sync for Device Implement Sync for Device in addition to Device. Device uses the same underlying struct pci_dev as Device; Bound is a zero-sized type-state marker that does not affect thread safety. This is needed for drivers to store &'bound pci::Device in their private data while remaining Send. Reviewed-by: Alexandre Courbot Reviewed-by: Gary Guo Reviewed-by: Greg Kroah-Hartman Acked-by: Uwe Kleine-König Tested-by: Dirk Behme Link: https://patch.msgid.link/20260525202921.124698-7-dakr@kernel.org Signed-off-by: Danilo Krummrich --- 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) are thread safe. unsafe impl Sync for Device {} + +// SAFETY: Same as `Device` -- 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 {}