Skip to contentSkip to conversation

net: phylink: use for_each_set_bit()

PATCH Applied Russell King (Oracle) 3 participants 3 messages Nov 19, 2023 – Nov 21, 2023

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 net: phylink: use for_each_set_bit()

Use for_each_set_bit() rather than open coding the for() test_bit() loop.

---
 drivers/net/phy/phylink.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)
drivers/net/phy/phylink.c +8 -10
index d2fa949ff1ea..c276f9482f78 100644
@@ -697,18 +697,16 @@ static int phylink_validate_mask(struct phylink *pl, unsigned long *supported,
 	__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);
 		}
 	}
 
Signature · 1 line
2.30.2
Reviewed-by on v2 1/1
#1 lore raw
Quoted 6 lines · Russell King (Oracle)

Use for_each_set_bit() rather than open coding the for() test_bit() loop.

---

Nice cleanup,

Quoted 34 lines
 drivers/net/phy/phylink.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)
drivers/net/phy/phylink.c +8 -10
index d2fa949ff1ea..c276f9482f78 100644
@@ -697,18 +697,16 @@ static int phylink_validate_mask(struct phylink *pl, unsigned long *supported,
 	__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);
 		}
 	}
 
#2 lore raw
In reply to Russell King (Oracle)
This patch was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:

Quoted 8 lines · On Sun, 19 Nov 2023 21:07:43 +0000 you wrote:

Use for_each_set_bit() rather than open coding the for() test_bit() loop.

---
 drivers/net/phy/phylink.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

Here is the summary with links:
- [net-next,v2] net: phylink: use for_each_set_bit()

    https://git.kernel.org/netdev/net-next/c/335662889f5a

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html