Combine the three link mode masks in a single operation and use its
return value to determine whether EEE is active.

Signed-off-by: Yury Norov <[email protected]>
---
 drivers/net/usb/r8152.c  | 10 ++++------
 include/linux/linkmode.h |  8 ++++++++
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index f61686433031..75f0574fe1d4 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -9149,9 +9149,8 @@ static int r8152_get_eee(struct r8152 *tp, struct 
ethtool_keee *eee)
        if (speed & _100bps)
                linkmode_set_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT, common);
 
-       linkmode_and(common, common, eee->advertised);
-       linkmode_and(common, common, eee->lp_advertised);
-       eee->eee_active = !linkmode_empty(common);
+       eee->eee_active = linkmode_and_and(common, common, eee->advertised,
+                                          eee->lp_advertised);
 
        return 0;
 }
@@ -9222,9 +9221,8 @@ static int r8153_get_eee(struct r8152 *tp, struct 
ethtool_keee *eee)
        if (speed & _100bps)
                linkmode_set_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT, common);
 
-       linkmode_and(common, common, eee->advertised);
-       linkmode_and(common, common, eee->lp_advertised);
-       eee->eee_active = !linkmode_empty(common);
+       eee->eee_active = linkmode_and_and(common, common, eee->advertised,
+                                          eee->lp_advertised);
 
        return 0;
 }
diff --git a/include/linux/linkmode.h b/include/linux/linkmode.h
index 49587a2e0f69..efd392dc62ae 100644
--- a/include/linux/linkmode.h
+++ b/include/linux/linkmode.h
@@ -26,6 +26,14 @@ static inline bool linkmode_and(unsigned long *dst, const 
unsigned long *a,
        return bitmap_and(dst, a, b, __ETHTOOL_LINK_MODE_MASK_NBITS);
 }
 
+static inline bool linkmode_and_and(unsigned long *dst,
+                                   const unsigned long *a,
+                                   const unsigned long *b,
+                                   const unsigned long *c)
+{
+       return bitmap_and_and(dst, a, b, c, __ETHTOOL_LINK_MODE_MASK_NBITS);
+}
+
 static inline bool linkmode_and_andnot(unsigned long *dst,
                                       const unsigned long *a,
                                       const unsigned long *b,
-- 
2.53.0

Reply via email to