diff options
author | Russell King <rmk+kernel@armlinux.org.uk> | 2018-01-02 05:58:53 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-01-03 11:00:23 -0500 |
commit | 2b74e5be17d25fbca4be236a19efcd2ecae81cb2 (patch) | |
tree | eac566f8ce3c6b9619783cbcbad5006f5d3e2500 | |
parent | 424ca4c5512173e42b4086322dafd33ee882baf3 (diff) |
net: phy: add phy_modify() accessor
Add phy_modify() convenience accessor to complement the mdiobus
counterpart.
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>
-rw-r--r-- | drivers/net/phy/phy-core.c | 23 | ||||
-rw-r--r-- | include/linux/phy.h | 1 |
2 files changed, 24 insertions, 0 deletions
diff --git a/drivers/net/phy/phy-core.c b/drivers/net/phy/phy-core.c index 48e762bf6464..44d09b192014 100644 --- a/drivers/net/phy/phy-core.c +++ b/drivers/net/phy/phy-core.c | |||
@@ -349,6 +349,29 @@ int __phy_modify(struct phy_device *phydev, u32 regnum, u16 mask, u16 set) | |||
349 | } | 349 | } |
350 | EXPORT_SYMBOL_GPL(__phy_modify); | 350 | EXPORT_SYMBOL_GPL(__phy_modify); |
351 | 351 | ||
352 | /** | ||
353 | * phy_modify - Convenience function for modifying a given PHY register | ||
354 | * @phydev: the phy_device struct | ||
355 | * @regnum: register number to write | ||
356 | * @mask: bit mask of bits to clear | ||
357 | * @set: new value of bits set in mask to write to @regnum | ||
358 | * | ||
359 | * NOTE: MUST NOT be called from interrupt context, | ||
360 | * because the bus read/write functions may wait for an interrupt | ||
361 | * to conclude the operation. | ||
362 | */ | ||
363 | int phy_modify(struct phy_device *phydev, u32 regnum, u16 mask, u16 set) | ||
364 | { | ||
365 | int ret; | ||
366 | |||
367 | mutex_lock(&phydev->mdio.bus->mdio_lock); | ||
368 | ret = __phy_modify(phydev, regnum, mask, set); | ||
369 | mutex_unlock(&phydev->mdio.bus->mdio_lock); | ||
370 | |||
371 | return ret; | ||
372 | } | ||
373 | EXPORT_SYMBOL_GPL(phy_modify); | ||
374 | |||
352 | static int __phy_read_page(struct phy_device *phydev) | 375 | static int __phy_read_page(struct phy_device *phydev) |
353 | { | 376 | { |
354 | return phydev->drv->read_page(phydev); | 377 | return phydev->drv->read_page(phydev); |
diff --git a/include/linux/phy.h b/include/linux/phy.h index af1a740dafd4..135aba5c3d39 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h | |||
@@ -762,6 +762,7 @@ static inline int __phy_write(struct phy_device *phydev, u32 regnum, u16 val) | |||
762 | } | 762 | } |
763 | 763 | ||
764 | int __phy_modify(struct phy_device *phydev, u32 regnum, u16 mask, u16 set); | 764 | int __phy_modify(struct phy_device *phydev, u32 regnum, u16 mask, u16 set); |
765 | int phy_modify(struct phy_device *phydev, u32 regnum, u16 mask, u16 set); | ||
765 | 766 | ||
766 | /** | 767 | /** |
767 | * phy_interrupt_is_valid - Convenience function for testing a given PHY irq | 768 | * phy_interrupt_is_valid - Convenience function for testing a given PHY irq |