Skip to content

Commit ccc27fc

Browse files
committed
Merge branch 'phy-add-helpers-for-setting-clearing-bits-in-PHY-registers'
Heiner Kallweit says: ==================== phy: add helpers for setting/clearing bits in PHY registers Based on the recent introduction of phy_modify add helpers for setting and clearing bits in PHY registers. First user is phylib. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 79d891c + 032f470 commit ccc27fc

File tree

2 files changed

+51
-2
lines changed

2 files changed

+51
-2
lines changed

drivers/net/phy/phy_device.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1660,13 +1660,13 @@ EXPORT_SYMBOL(genphy_config_init);
16601660

16611661
int genphy_suspend(struct phy_device *phydev)
16621662
{
1663-
return phy_modify(phydev, MII_BMCR, 0, BMCR_PDOWN);
1663+
return phy_set_bits(phydev, MII_BMCR, BMCR_PDOWN);
16641664
}
16651665
EXPORT_SYMBOL(genphy_suspend);
16661666

16671667
int genphy_resume(struct phy_device *phydev)
16681668
{
1669-
return phy_modify(phydev, MII_BMCR, BMCR_PDOWN, 0);
1669+
return phy_clear_bits(phydev, MII_BMCR, BMCR_PDOWN);
16701670
}
16711671
EXPORT_SYMBOL(genphy_resume);
16721672

include/linux/phy.h

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,55 @@ static inline int __phy_write(struct phy_device *phydev, u32 regnum, u16 val)
764764
int __phy_modify(struct phy_device *phydev, u32 regnum, u16 mask, u16 set);
765765
int phy_modify(struct phy_device *phydev, u32 regnum, u16 mask, u16 set);
766766

767+
/**
768+
* __phy_set_bits - Convenience function for setting bits in a PHY register
769+
* @phydev: the phy_device struct
770+
* @regnum: register number to write
771+
* @val: bits to set
772+
*
773+
* The caller must have taken the MDIO bus lock.
774+
*/
775+
static inline int __phy_set_bits(struct phy_device *phydev, u32 regnum, u16 val)
776+
{
777+
return __phy_modify(phydev, regnum, 0, val);
778+
}
779+
780+
/**
781+
* __phy_clear_bits - Convenience function for clearing bits in a PHY register
782+
* @phydev: the phy_device struct
783+
* @regnum: register number to write
784+
* @val: bits to clear
785+
*
786+
* The caller must have taken the MDIO bus lock.
787+
*/
788+
static inline int __phy_clear_bits(struct phy_device *phydev, u32 regnum,
789+
u16 val)
790+
{
791+
return __phy_modify(phydev, regnum, val, 0);
792+
}
793+
794+
/**
795+
* phy_set_bits - Convenience function for setting bits in a PHY register
796+
* @phydev: the phy_device struct
797+
* @regnum: register number to write
798+
* @val: bits to set
799+
*/
800+
static inline int phy_set_bits(struct phy_device *phydev, u32 regnum, u16 val)
801+
{
802+
return phy_modify(phydev, regnum, 0, val);
803+
}
804+
805+
/**
806+
* phy_clear_bits - Convenience function for clearing bits in a PHY register
807+
* @phydev: the phy_device struct
808+
* @regnum: register number to write
809+
* @val: bits to clear
810+
*/
811+
static inline int phy_clear_bits(struct phy_device *phydev, u32 regnum, u16 val)
812+
{
813+
return phy_modify(phydev, regnum, val, 0);
814+
}
815+
767816
/**
768817
* phy_interrupt_is_valid - Convenience function for testing a given PHY irq
769818
* @phydev: the phy_device struct

0 commit comments

Comments
 (0)