diff options
author | Russell King (Oracle) <rmk+kernel@armlinux.org.uk> | 2021-10-06 14:19:20 +0200 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2021-10-07 02:49:16 +0200 |
commit | 79365f36d1de87286bb4fc0abcb2a01678ef4bef (patch) | |
tree | 86863cc6016515a3f61464d48287e64f65621b12 /drivers/net/phy/mdio_bus.c | |
parent | Merge branch 'ethtool-add-ability-to-control-transceiver-modules-power-mode' (diff) | |
download | linux-79365f36d1de87286bb4fc0abcb2a01678ef4bef.tar.xz linux-79365f36d1de87286bb4fc0abcb2a01678ef4bef.zip |
net: mdio: add mdiobus_modify_changed()
Add mdiobus_modify_changed() helper to reflect the phylib and similar
equivalents. This will avoid this functionality being open-coded, as
has already happened in phylink, and it looks like other users will be
appearing soon.
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'drivers/net/phy/mdio_bus.c')
-rw-r--r-- | drivers/net/phy/mdio_bus.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index 6f4b4e5df639..d8b68145f6b4 100644 --- a/drivers/net/phy/mdio_bus.c +++ b/drivers/net/phy/mdio_bus.c @@ -927,6 +927,28 @@ int mdiobus_modify(struct mii_bus *bus, int addr, u32 regnum, u16 mask, u16 set) EXPORT_SYMBOL_GPL(mdiobus_modify); /** + * mdiobus_modify_changed - Convenience function for modifying a given mdio + * device register and returning if it changed + * @bus: the mii_bus struct + * @addr: the phy address + * @regnum: register number to write + * @mask: bit mask of bits to clear + * @set: bit mask of bits to set + */ +int mdiobus_modify_changed(struct mii_bus *bus, int addr, u32 regnum, + u16 mask, u16 set) +{ + int err; + + mutex_lock(&bus->mdio_lock); + err = __mdiobus_modify_changed(bus, addr, regnum, mask, set); + mutex_unlock(&bus->mdio_lock); + + return err; +} +EXPORT_SYMBOL_GPL(mdiobus_modify_changed); + +/** * mdio_bus_match - determine if given MDIO driver supports the given * MDIO device * @dev: target MDIO device |