Skip to content

Commit ac8322d

Browse files
hkallweitdavem330
authored andcommitted
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. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 79d891c commit ac8322d

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

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)