Code that holds the MDIO bus across a burst of transactions has phy_lock_mdio_bus(), which needs a phy_device. A library serving a chip before its phy_device exists has to open-code the same mutex. Add the mdio_device spelling beside it. The nested form is for a library whose caller already holds the bus one level up, which is what the EN8811H MDIO driver later in this series does. Assisted-by: LLM Signed-off-by: Aleksei Sviridkin --- include/linux/phy.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/include/linux/phy.h b/include/linux/phy.h index 3d8afe6b7f1c..e74a8f5cf5c6 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -2284,6 +2284,22 @@ 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); +} + +/* For a bus reached through another one, as mdiobus_read_nested() is. */ +static inline void mdiodev_lock_nested(struct mdio_device *mdiodev) +{ + mutex_lock_nested(&mdiodev->bus->mdio_lock, MDIO_MUTEX_NESTED); +} + +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