Skip to content

Commit

Permalink
net: phy: replace mutex_is_locked with lockdep_assert_held in phylib
Browse files Browse the repository at this point in the history
Switch to lockdep_assert_held(_once), similar to what is being done
in other subsystems. One advantage is that there's zero runtime
overhead if lockdep support isn't enabled.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://lore.kernel.org/r/ccc40b9d-8ee0-43a1-5009-2cc95ca79c85@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Heiner Kallweit authored and Jakub Kicinski committed Jan 7, 2021
1 parent 8b86850 commit e6e918d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions drivers/net/phy/mdio_bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ int __mdiobus_read(struct mii_bus *bus, int addr, u32 regnum)
{
int retval;

WARN_ON_ONCE(!mutex_is_locked(&bus->mdio_lock));
lockdep_assert_held_once(&bus->mdio_lock);

retval = bus->read(bus, addr, regnum);

Expand All @@ -766,7 +766,7 @@ int __mdiobus_write(struct mii_bus *bus, int addr, u32 regnum, u16 val)
{
int err;

WARN_ON_ONCE(!mutex_is_locked(&bus->mdio_lock));
lockdep_assert_held_once(&bus->mdio_lock);

err = bus->write(bus, addr, regnum, val);

Expand Down
2 changes: 1 addition & 1 deletion drivers/net/phy/phy.c
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ static int phy_check_link_status(struct phy_device *phydev)
{
int err;

WARN_ON(!mutex_is_locked(&phydev->lock));
lockdep_assert_held(&phydev->lock);

/* Keep previous state if loopback is enabled because some PHYs
* report that Link is Down when loopback is enabled.
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/phy/phy_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -1740,7 +1740,7 @@ int __phy_resume(struct phy_device *phydev)
struct phy_driver *phydrv = phydev->drv;
int ret;

WARN_ON(!mutex_is_locked(&phydev->lock));
lockdep_assert_held(&phydev->lock);

if (!phydrv || !phydrv->resume)
return 0;
Expand Down

0 comments on commit e6e918d

Please sign in to comment.