aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHeiner Kallweit <hkallweit1@gmail.com>2019-08-09 14:44:22 -0400
committerDavid S. Miller <davem@davemloft.net>2019-08-12 00:24:32 -0400
commitbf22b343ca800aac076ccf986e762b28545aa6bb (patch)
treeb8e3b79eb675611450306d470000c5b39c3e8b1f
parentf4069cd7fa6583e7094001c6fce6f426d17a4c76 (diff)
net: phy: add phy_modify_paged_changed
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>
-rw-r--r--drivers/net/phy/phy-core.c29
-rw-r--r--include/linux/phy.h2
2 files changed, 26 insertions, 5 deletions
diff --git a/drivers/net/phy/phy-core.c b/drivers/net/phy/phy-core.c
index 16667fbac8bf..9ae3abb2daca 100644
--- a/drivers/net/phy/phy-core.c
+++ b/drivers/net/phy/phy-core.c
@@ -783,24 +783,43 @@ int phy_write_paged(struct phy_device *phydev, int page, u32 regnum, u16 val)
783EXPORT_SYMBOL(phy_write_paged); 783EXPORT_SYMBOL(phy_write_paged);
784 784
785/** 785/**
786 * phy_modify_paged() - Convenience function for modifying a paged register 786 * phy_modify_paged_changed() - Function for modifying a paged register
787 * @phydev: a pointer to a &struct phy_device 787 * @phydev: a pointer to a &struct phy_device
788 * @page: the page for the phy 788 * @page: the page for the phy
789 * @regnum: register number 789 * @regnum: register number
790 * @mask: bit mask of bits to clear 790 * @mask: bit mask of bits to clear
791 * @set: bit mask of bits to set 791 * @set: bit mask of bits to set
792 * 792 *
793 * Same rules as for phy_read() and phy_write(). 793 * Returns negative errno, 0 if there was no change, and 1 in case of change
794 */ 794 */
795int phy_modify_paged(struct phy_device *phydev, int page, u32 regnum, 795int phy_modify_paged_changed(struct phy_device *phydev, int page, u32 regnum,
796 u16 mask, u16 set) 796 u16 mask, u16 set)
797{ 797{
798 int ret = 0, oldpage; 798 int ret = 0, oldpage;
799 799
800 oldpage = phy_select_page(phydev, page); 800 oldpage = phy_select_page(phydev, page);
801 if (oldpage >= 0) 801 if (oldpage >= 0)
802 ret = __phy_modify(phydev, regnum, mask, set); 802 ret = __phy_modify_changed(phydev, regnum, mask, set);
803 803
804 return phy_restore_page(phydev, oldpage, ret); 804 return phy_restore_page(phydev, oldpage, ret);
805} 805}
806EXPORT_SYMBOL(phy_modify_paged_changed);
807
808/**
809 * phy_modify_paged() - Convenience function for modifying a paged register
810 * @phydev: a pointer to a &struct phy_device
811 * @page: the page for the phy
812 * @regnum: register number
813 * @mask: bit mask of bits to clear
814 * @set: bit mask of bits to set
815 *
816 * Same rules as for phy_read() and phy_write().
817 */
818int phy_modify_paged(struct phy_device *phydev, int page, u32 regnum,
819 u16 mask, u16 set)
820{
821 int ret = phy_modify_paged_changed(phydev, page, regnum, mask, set);
822
823 return ret < 0 ? ret : 0;
824}
806EXPORT_SYMBOL(phy_modify_paged); 825EXPORT_SYMBOL(phy_modify_paged);
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 7117825ee57a..781f4810ceba 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -984,6 +984,8 @@ int phy_select_page(struct phy_device *phydev, int page);
984int phy_restore_page(struct phy_device *phydev, int oldpage, int ret); 984int phy_restore_page(struct phy_device *phydev, int oldpage, int ret);
985int phy_read_paged(struct phy_device *phydev, int page, u32 regnum); 985int phy_read_paged(struct phy_device *phydev, int page, u32 regnum);
986int phy_write_paged(struct phy_device *phydev, int page, u32 regnum, u16 val); 986int phy_write_paged(struct phy_device *phydev, int page, u32 regnum, u16 val);
987int phy_modify_paged_changed(struct phy_device *phydev, int page, u32 regnum,
988 u16 mask, u16 set);
987int phy_modify_paged(struct phy_device *phydev, int page, u32 regnum, 989int phy_modify_paged(struct phy_device *phydev, int page, u32 regnum,
988 u16 mask, u16 set); 990 u16 mask, u16 set);
989 991