Thread (20 messages) 20 messages, 3 authors, 2026-02-24
STALE141d
Revisions (4)
  1. v1 [diff vs current]
  2. v1 [diff vs current]
  3. v2 [diff vs current]
  4. v3 current

[PATCH net-next v3 1/2] rust: net: phy: add speed() getter to Device

From: Artem Lytkin <hidden>
Date: 2026-02-24 16:49:30
Also in: lkml, rust-for-linux
Subsystem: ethernet phy library [rust], rust, the rest · Maintainers: FUJITA Tomonori, Miguel Ojeda, Linus Torvalds

Add a speed() getter to phy::Device that reads the current link speed
from the phy_device struct. This is needed by PHY drivers that must
detect speed changes in their read_status callback.

Signed-off-by: Artem Lytkin <redacted>
---
 rust/kernel/net/phy.rs | 8 ++++++++
 1 file changed, 8 insertions(+)
diff --git a/rust/kernel/net/phy.rs b/rust/kernel/net/phy.rs
index 3ca99db5cccf..3812f8fd3e49 100644
--- a/rust/kernel/net/phy.rs
+++ b/rust/kernel/net/phy.rs
@@ -158,6 +158,14 @@ pub fn is_autoneg_completed(&self) -> bool {
         bit_field.get(15, 1) == AUTONEG_COMPLETED
     }
 
+    /// Gets the current link speed.
+    pub fn speed(&self) -> i32 {
+        let phydev = self.0.get();
+        // SAFETY: The struct invariant ensures that we may access
+        // this field without additional synchronization.
+        unsafe { (*phydev).speed }
+    }
+
     /// Sets the speed of the PHY.
     pub fn set_speed(&mut self, speed: u32) {
         let phydev = self.0.get();
-- 
2.43.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help