net: phylink: use more linkmode_*
authorRussell King <rmk+kernel@armlinux.org.uk>
Tue, 15 Oct 2019 10:28:46 +0000 (11:28 +0100)
committerDavid S. Miller <davem@davemloft.net>
Wed, 16 Oct 2019 03:40:06 +0000 (20:40 -0700)
Use more linkmode_* helpers rather than open-coding the bitmap
operations.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/phy/phylink.c
include/linux/linkmode.h

index a5a57ca94c1ac541092867b685fe7d616218f96b..8e53ed90da3c94a69dbee6775215774a24224e77 100644 (file)
@@ -117,9 +117,7 @@ static int phylink_is_empty_linkmode(const unsigned long *linkmode)
        phylink_set(tmp, Pause);
        phylink_set(tmp, Asym_Pause);
 
-       bitmap_andnot(tmp, linkmode, tmp, __ETHTOOL_LINK_MODE_MASK_NBITS);
-
-       return linkmode_empty(tmp);
+       return linkmode_subset(linkmode, tmp);
 }
 
 static const char *phylink_an_mode_str(unsigned int mode)
@@ -1728,8 +1726,7 @@ static int phylink_sfp_module_insert(void *upstream,
        if (phy_interface_mode_is_8023z(iface) && pl->phydev)
                return -EINVAL;
 
-       changed = !bitmap_equal(pl->supported, support,
-                               __ETHTOOL_LINK_MODE_MASK_NBITS);
+       changed = !linkmode_equal(pl->supported, support);
        if (changed) {
                linkmode_copy(pl->supported, support);
                linkmode_copy(pl->link_config.advertising, config.advertising);
index a99c58866860e2e418f342a87f6372330d7f1045..fe740031339de8fafea6e395e7b848e2f6a32ce6 100644 (file)
@@ -82,4 +82,10 @@ static inline int linkmode_equal(const unsigned long *src1,
        return bitmap_equal(src1, src2, __ETHTOOL_LINK_MODE_MASK_NBITS);
 }
 
+static inline int linkmode_subset(const unsigned long *src1,
+                                 const unsigned long *src2)
+{
+       return bitmap_subset(src1, src2, __ETHTOOL_LINK_MODE_MASK_NBITS);
+}
+
 #endif /* __LINKMODE_H */