diff options
author | Russell King (Oracle) <rmk+kernel@armlinux.org.uk> | 2021-06-08 14:43:54 +0100 |
---|---|---|
committer | Russell King (Oracle) <rmk+kernel@armlinux.org.uk> | 2021-09-19 13:22:14 +0100 |
commit | f1d717845dc84420883e9853a588a5bd60ba93b2 (patch) | |
tree | ae14f781e8d9474d73698c423dfe41c0e6a3ca76 | |
parent | 2b5d092a5727f4d0931b3c3823e5013f74024180 (diff) |
net: phy: add phy_interface_t bitmap support
Add support for a bitmap for phy interface modes, which includes:
- a macro to declare the interface bitmap
- an inline helper to zero the interface bitmap
- an inline helper to detect an empty interface bitmap
- an inline helper to do a bitwise AND operation on two interface
bitmaps
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
-rw-r--r-- | include/linux/phy.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/include/linux/phy.h b/include/linux/phy.h index 3b80dc3ed68b..1472657a8136 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -155,6 +155,26 @@ typedef enum { PHY_INTERFACE_MODE_MAX, } phy_interface_t; +/* PHY interface mode bitmap handling */ +#define DECLARE_PHY_INTERFACE_MASK(name) \ + DECLARE_BITMAP(name, PHY_INTERFACE_MODE_MAX) + +static inline void phy_interface_zero(unsigned long *intf) +{ + bitmap_zero(intf, PHY_INTERFACE_MODE_MAX); +} + +static inline bool phy_interface_empty(const unsigned long *intf) +{ + return bitmap_empty(intf, PHY_INTERFACE_MODE_MAX); +} + +static inline void phy_interface_and(unsigned long *dst, const unsigned long *a, + const unsigned long *b) +{ + bitmap_and(dst, a, b, PHY_INTERFACE_MODE_MAX); +} + /* * phy_supported_speeds - return all speeds currently supported by a PHY device */ |