diff mbox series

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

Message ID E1r3yPo-00CnKQ-JG@rmk-PC.armlinux.org.uk (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [net-next] net: phylink: use for_each_set_bit() | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
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 warning CHECK: Please don't use multiple blank lines
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. 17, 2023, 12:57 p.m. UTC
Use for_each_set_bit() rather than open coding the for() test_bit()
loop.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 drivers/net/phy/phylink.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

Comments

Andrew Lunn Nov. 17, 2023, 4:15 p.m. UTC | #1
> +		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);
>  		}
>  	}
>  
> +
>  	linkmode_copy(supported, all_s);

Adding another blank line here was probably unintentional?

Otherwise:

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew
Russell King (Oracle) Nov. 17, 2023, 4:17 p.m. UTC | #2
On Fri, Nov 17, 2023 at 05:15:17PM +0100, Andrew Lunn wrote:
> > +		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);
> >  		}
> >  	}
> >  
> > +
> >  	linkmode_copy(supported, all_s);
> 
> Adding another blank line here was probably unintentional?

Hmm, indeed, thanks for spotting. I always forget whether I'll need to
send a v2 for something this trivial or whether netdev folk will fix
it up when committing it. I'm happy to resend.

> Otherwise:
> 
> Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew Lunn Nov. 17, 2023, 4:30 p.m. UTC | #3
> Hmm, indeed, thanks for spotting. I always forget whether I'll need to
> send a v2 for something this trivial or whether netdev folk will fix
> it up when committing it. I'm happy to resend.

You should resend. netdev patch acceptance is pretty bot driven, with
the normal 'fast path' not allowing the patch to be edited by the
merger.

	Andrew
Russell King (Oracle) Nov. 17, 2023, 4:32 p.m. UTC | #4
On Fri, Nov 17, 2023 at 05:30:41PM +0100, Andrew Lunn wrote:
> > Hmm, indeed, thanks for spotting. I always forget whether I'll need to
> > send a v2 for something this trivial or whether netdev folk will fix
> > it up when committing it. I'm happy to resend.
> 
> You should resend. netdev patch acceptance is pretty bot driven, with
> the normal 'fast path' not allowing the patch to be edited by the
> merger.

I think it does happen sometimes? Or maybe I'm misremembering with other
subsystems...
diff mbox series

Patch

diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index d2fa949ff1ea..4d0f39410ad0 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -697,21 +697,20 @@  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);
 		}
 	}
 
+
 	linkmode_copy(supported, all_s);
 	linkmode_copy(state->advertising, all_adv);