summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell King (Oracle) <rmk+kernel@armlinux.org.uk>2021-06-08 14:43:54 +0100
committerRussell King (Oracle) <rmk+kernel@armlinux.org.uk>2021-06-29 14:23:08 +0100
commitabe98e0c4998ba8ac4f425476d76b63cbedaa3ff (patch)
treecb6e61d1db488c0abe2ff0dce7abae6bf9585913
parentced3b4d9baa3be5fc844e59182c12786d5466f56 (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.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 852743f07e3e..2e9b897d8872 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -151,6 +151,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
*/