From 85631f5b33f2acce7d42dec1d0a062ab40de95b8 Mon Sep 17 00:00:00 2001 From: "Russell King (Oracle)" Date: Sun, 19 Nov 2023 21:07:43 +0000 Subject: [PATCH 2/7] net: phylink: use for_each_set_bit() Use for_each_set_bit() rather than open coding the for() test_bit() loop. Reviewed-by: Andrew Lunn Signed-off-by: Russell King (Oracle) Reviewed-by: Wojciech Drewek Link: https://lore.kernel.org/r/E1r4p15-00Cpxe-C7@rmk-PC.armlinux.org.uk Signed-off-by: Paolo Abeni --- drivers/net/phy/phylink.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -712,18 +712,16 @@ static int phylink_validate_mask(struct __ETHTOOL_DECLARE_LINK_MODE_MASK(all_s) = { 0, }; __ETHTOOL_DECLARE_LINK_MODE_MASK(s); struct phylink_link_state t; - int intf; + int interface; - for (intf = 0; intf < PHY_INTERFACE_MODE_MAX; intf++) { - if (test_bit(intf, interfaces)) { - linkmode_copy(s, supported); + for_each_set_bit(interface, interfaces, PHY_INTERFACE_MODE_MAX) { + linkmode_copy(s, supported); - t = *state; - t.interface = intf; - if (!phylink_validate_mac_and_pcs(pl, s, &t)) { - linkmode_or(all_s, all_s, s); - linkmode_or(all_adv, all_adv, t.advertising); - } + t = *state; + t.interface = interface; + if (!phylink_validate_mac_and_pcs(pl, s, &t)) { + linkmode_or(all_s, all_s, s); + linkmode_or(all_adv, all_adv, t.advertising); } }