[PATCH v2 1/5] rust: phy: implement `Send` for `Registration`

From: Wedson Almeida Filho
Date: Thu Mar 28 2024 - 15:58:48 EST


From: Wedson Almeida Filho <walmeida@xxxxxxxxxxxxx>

In preparation for requiring `Send` for `Module` implementations in the
next patch.

Cc: FUJITA Tomonori <fujita.tomonori@xxxxxxxxx>
Cc: Trevor Gross <tmgross@xxxxxxxxx>
Cc: netdev@xxxxxxxxxxxxxxx
Signed-off-by: Wedson Almeida Filho <walmeida@xxxxxxxxxxxxx>
---
rust/kernel/net/phy.rs | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/rust/kernel/net/phy.rs b/rust/kernel/net/phy.rs
index 96e09c6e8530..265d0e1c1371 100644
--- a/rust/kernel/net/phy.rs
+++ b/rust/kernel/net/phy.rs
@@ -640,6 +640,10 @@ pub struct Registration {
drivers: Pin<&'static mut [DriverVTable]>,
}

+// SAFETY: The only action allowed in a `Registration` instance is dropping it, which is safe to do
+// from any thread because `phy_drivers_unregister` can be called from any thread context.
+unsafe impl Send for Registration {}
+
impl Registration {
/// Registers a PHY driver.
pub fn register(
--
2.34.1