[PATCH 1/2] rust: pci: require Send for Driver trait implementers

From: Danilo Krummrich
Date: Wed Mar 19 2025 - 11:02:25 EST


The instance of Self, returned and created by Driver::probe() is
dropped in the bus' remove() callback.

Request implementers of the Driver trait to implement Send, since the
remove() callback is not guaranteed to run from the same thread as
probe().

Fixes: 1bd8b6b2c5d3 ("rust: pci: add basic PCI device / driver abstractions")
Reported-by: Alice Ryhl <aliceryhl@xxxxxxxxxx>
Closes: https://lore.kernel.org/lkml/Z9rDxOJ2V2bPjj5i@xxxxxxxxxx/
Signed-off-by: Danilo Krummrich <dakr@xxxxxxxxxx>
---
rust/kernel/pci.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/rust/kernel/pci.rs b/rust/kernel/pci.rs
index 0d09ae34a64d..22a32172b108 100644
--- a/rust/kernel/pci.rs
+++ b/rust/kernel/pci.rs
@@ -222,7 +222,7 @@ macro_rules! pci_device_table {
///```
/// Drivers must implement this trait in order to get a PCI driver registered. Please refer to the
/// `Adapter` documentation for an example.
-pub trait Driver {
+pub trait Driver: Send {
/// The type holding information about each device id supported by the driver.
///
/// TODO: Use associated_type_defaults once stabilized:
--
2.48.1