aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/phy/phy-core.c23
-rw-r--r--include/linux/phy.h1
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}
350EXPORT_SYMBOL_GPL(__phy_modify); 350EXPORT_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 */
363int 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}
373EXPORT_SYMBOL_GPL(phy_modify);
374
352static int __phy_read_page(struct phy_device *phydev) 375static 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
764int __phy_modify(struct phy_device *phydev, u32 regnum, u16 mask, u16 set); 764int __phy_modify(struct phy_device *phydev, u32 regnum, u16 mask, u16 set);
765int 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