diff mbox series

[net-next,v2] net: phylink: use for_each_set_bit()

Message ID E1r4p15-00Cpxe-C7@rmk-PC.armlinux.org.uk (mailing list archive)
State Accepted
Commit 335662889f5a5f4d5668ed6c8b5fd58913d91d15
Delegated to: Netdev Maintainers
Headers show
Series [net-next,v2] net: phylink: use for_each_set_bit() | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/codegen success Generated files up to date
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1127 this patch: 1127
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 1154 this patch: 1154
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1154 this patch: 1154
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 26 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Russell King (Oracle) Nov. 19, 2023, 9:07 p.m. UTC
Use for_each_set_bit() rather than open coding the for() test_bit()
loop.

Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 drivers/net/phy/phylink.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

Comments

Wojciech Drewek Nov. 20, 2023, 12:04 p.m. UTC | #1
On 19.11.2023 22:07, Russell King (Oracle) wrote:
> Use for_each_set_bit() rather than open coding the for() test_bit()
> loop.
> 
> Reviewed-by: Andrew Lunn <andrew@lunn.ch>
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
> ---

Nice cleanup,
Reviewed-by: Wojciech Drewek <wojciech.drewek@intel.com>

>  drivers/net/phy/phylink.c | 18 ++++++++----------
>  1 file changed, 8 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
> index d2fa949ff1ea..c276f9482f78 100644
> --- a/drivers/net/phy/phylink.c
> +++ b/drivers/net/phy/phylink.c
> @@ -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);
>  		}
>  	}
>
patchwork-bot+netdevbpf@kernel.org Nov. 21, 2023, 12:30 p.m. UTC | #2
Hello:

This patch was applied to netdev/net-next.git (main)
by Paolo Abeni <pabeni@redhat.com>:

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.
> 
> Reviewed-by: Andrew Lunn <andrew@lunn.ch>
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
> ---
>  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!
diff mbox series

Patch

diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index d2fa949ff1ea..c276f9482f78 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -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);
 		}
 	}