Thread (11 messages) flat view 11 messages, 1 author, 2d ago
WARM2d

Revision v2 of 2 in this series.

Revisions (2)
  1. rfc [diff vs current]
  2. v2 current

[RFC PATCH net-next v2 03/10] net: phy: add mdiodev_lock() and mdiodev_unlock()

From: Aleksei Sviridkin <hidden>
Date: 2026-09-04 19:03:14
Also in: lkml, netdev
Subsystem: ethernet phy library, the rest · Maintainers: Andrew Lunn, Heiner Kallweit, Linus Torvalds

The __mdiodev_* accessors require the caller to hold the MDIO bus
lock, but the wrappers that take it, phy_lock_mdio_bus() and
phy_unlock_mdio_bus(), need a phy_device. A driver bound to a plain
MDIO device has none, and must reach into mdiodev->bus->mdio_lock
itself.

They sit in phy.h beside those wrappers because struct mii_bus is
defined here, not in mdio.h where the accessors live.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <redacted>
---
 include/linux/phy.h | 10 ++++++++++
 1 file changed, 10 insertions(+)
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 3d8afe6b7f1c..8c10c8ae21b1 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -2284,6 +2284,16 @@ static inline void phy_unlock_mdio_bus(struct phy_device *phydev)
 	mutex_unlock(&phydev->mdio.bus->mdio_lock);
 }
 
+static inline void mdiodev_lock(struct mdio_device *mdiodev)
+{
+	mutex_lock(&mdiodev->bus->mdio_lock);
+}
+
+static inline void mdiodev_unlock(struct mdio_device *mdiodev)
+{
+	mutex_unlock(&mdiodev->bus->mdio_lock);
+}
+
 void phy_attached_print(struct phy_device *phydev, const char *fmt, ...)
 	__printf(2, 3);
 char *phy_attached_info_irq(struct phy_device *phydev)
-- 
2.53.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