net: mdiobus: add APIs for modifying a MDIO device register

Add APIs for modifying a MDIO device register, similar to the existing
phy_modify() group of functions, but at mdiobus level instead.  Adapt
__phy_modify_changed() to use the new mdiobus level helper.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Russell King 2020-03-17 14:52:31 +00:00 committed by David S. Miller
parent 89e3e3ddcb
commit 6cc7cf8125
4 changed files with 79 additions and 31 deletions

View file

@ -754,6 +754,25 @@ static inline int __phy_write(struct phy_device *phydev, u32 regnum, u16 val)
val);
}
/**
* __phy_modify_changed() - Convenience function for modifying a PHY register
* @phydev: a pointer to a &struct phy_device
* @regnum: register number
* @mask: bit mask of bits to clear
* @set: bit mask of bits to set
*
* Unlocked helper function which allows a PHY register to be modified as
* new register value = (old register value & ~mask) | set
*
* Returns negative errno, 0 if there was no change, and 1 in case of change
*/
static inline int __phy_modify_changed(struct phy_device *phydev, u32 regnum,
u16 mask, u16 set)
{
return __mdiobus_modify_changed(phydev->mdio.bus, phydev->mdio.addr,
regnum, mask, set);
}
/**
* phy_read_mmd - Convenience function for reading a register
* from an MMD on a given PHY.