]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
net: phy: add phy_modify_paged_changed
authorHeiner Kallweit <hkallweit1@gmail.com>
Fri, 9 Aug 2019 18:44:22 +0000 (20:44 +0200)
committerDavid S. Miller <davem@davemloft.net>
Mon, 12 Aug 2019 04:24:32 +0000 (21:24 -0700)
Add helper function phy_modify_paged_changed, behavios is the same
as for phy_modify_changed.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/phy/phy-core.c
include/linux/phy.h

index 16667fbac8bfa232ca19702c601442023fbd6b0e..9ae3abb2daca1c1e9f5cb40a7fb0ee8344a49e01 100644 (file)
@@ -783,24 +783,43 @@ int phy_write_paged(struct phy_device *phydev, int page, u32 regnum, u16 val)
 EXPORT_SYMBOL(phy_write_paged);
 
 /**
- * phy_modify_paged() - Convenience function for modifying a paged register
+ * phy_modify_paged_changed() - Function for modifying a paged register
  * @phydev: a pointer to a &struct phy_device
  * @page: the page for the phy
  * @regnum: register number
  * @mask: bit mask of bits to clear
  * @set: bit mask of bits to set
  *
- * Same rules as for phy_read() and phy_write().
+ * Returns negative errno, 0 if there was no change, and 1 in case of change
  */
-int phy_modify_paged(struct phy_device *phydev, int page, u32 regnum,
-                    u16 mask, u16 set)
+int phy_modify_paged_changed(struct phy_device *phydev, int page, u32 regnum,
+                            u16 mask, u16 set)
 {
        int ret = 0, oldpage;
 
        oldpage = phy_select_page(phydev, page);
        if (oldpage >= 0)
-               ret = __phy_modify(phydev, regnum, mask, set);
+               ret = __phy_modify_changed(phydev, regnum, mask, set);
 
        return phy_restore_page(phydev, oldpage, ret);
 }
+EXPORT_SYMBOL(phy_modify_paged_changed);
+
+/**
+ * phy_modify_paged() - Convenience function for modifying a paged register
+ * @phydev: a pointer to a &struct phy_device
+ * @page: the page for the phy
+ * @regnum: register number
+ * @mask: bit mask of bits to clear
+ * @set: bit mask of bits to set
+ *
+ * Same rules as for phy_read() and phy_write().
+ */
+int phy_modify_paged(struct phy_device *phydev, int page, u32 regnum,
+                    u16 mask, u16 set)
+{
+       int ret = phy_modify_paged_changed(phydev, page, regnum, mask, set);
+
+       return ret < 0 ? ret : 0;
+}
 EXPORT_SYMBOL(phy_modify_paged);
index 7117825ee57a25333f549e1dc8d4b4a6ab4e7805..781f4810cebaf385716a3c48ad37089c6534bde5 100644 (file)
@@ -984,6 +984,8 @@ int phy_select_page(struct phy_device *phydev, int page);
 int phy_restore_page(struct phy_device *phydev, int oldpage, int ret);
 int phy_read_paged(struct phy_device *phydev, int page, u32 regnum);
 int phy_write_paged(struct phy_device *phydev, int page, u32 regnum, u16 val);
+int phy_modify_paged_changed(struct phy_device *phydev, int page, u32 regnum,
+                            u16 mask, u16 set);
 int phy_modify_paged(struct phy_device *phydev, int page, u32 regnum,
                     u16 mask, u16 set);