summaryrefslogtreecommitdiff
path: root/include/linux/phy.h
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@armlinux.org.uk>2020-02-04 15:47:27 +0000
committerRussell King <rmk+kernel@armlinux.org.uk>2020-04-02 19:45:31 +0100
commit5b76cc424b1afe23271a6320382731eeaad7bd46 (patch)
tree3162b6d1c1504b22245da979a12f25f210554b50 /include/linux/phy.h
parent9bda56257c0f6a0933414fbd336c964ed070e4e3 (diff)
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>
Diffstat (limited to 'include/linux/phy.h')
-rw-r--r--include/linux/phy.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/include/linux/phy.h b/include/linux/phy.h
index ac956ea1a87c..8f73e4ea288c 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -753,6 +753,25 @@ static inline int __phy_write(struct phy_device *phydev, u32 regnum, u16 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.
* @phydev: The phy_device struct