net: phylink: simplify phylink_parse_fixedlink()
Subsystems (4)
PATCH 1/1 net: phylink: simplify phylink_parse_fixedlink()
phylink_parse_fixedlink() wants to preserve the pause, asym_pause and autoneg bits in pl->supported. Rather than reading the bits into separate bools, zeroing pl->supported, and then setting them if they were previously set, use a mask and linkmode_and() to achieve the same result.
--- drivers/net/phy/phylink.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-)
drivers/net/phy/phylink.c +6 -13
@@ -764,8 +764,8 @@ static int phylink_validate(struct phylink *pl, unsigned long *supported,static int phylink_parse_fixedlink (struct phylink *pl,const struct fwnode_handle *fwnode) { +__ETHTOOL_DECLARE_LINK_MODE_MASK (mask) = {0 , };struct fwnode_handle *fixed_node; -bool pause, asym_pause, autoneg;const struct phy_setting *s;struct gpio_desc *desc;u32 speed;
@@ -838,22 +838,15 @@ static int phylink_parse_fixedlink(struct phylink *pl,linkmode_copy (pl->link_config.advertising, pl->supported);phylink_validate (pl, pl->supported, &pl->link_config); - pause =phylink_test (pl->supported, Pause); - asym_pause =phylink_test (pl->supported, Asym_Pause); - autoneg =phylink_test (pl->supported, Autoneg); s =phy_lookup_setting (pl->link_config.speed, pl->link_config.duplex, pl->supported, true); -linkmode_zero (pl->supported); -phylink_set (pl->supported,MII ); -if (pause) -phylink_set (pl->supported, Pause); +linkmode_set_bit (ETHTOOL_LINK_MODE_Pause_BIT, mask); +linkmode_set_bit (ETHTOOL_LINK_MODE_Asym_Pause_BIT, mask); +linkmode_set_bit (ETHTOOL_LINK_MODE_Autoneg_BIT, mask); +linkmode_and (pl->supported, pl->supported, mask); -if (asym_pause) -phylink_set (pl->supported, Asym_Pause); - -if (autoneg) -phylink_set (pl->supported, Autoneg); +phylink_set (pl->supported,MII );if (s) {__set_bit (s->bit, pl->supported);
Signature · 1 line
2.30.2
Quoted 7 lines · Russell King (Oracle)
phylink_parse_fixedlink()wants to preserve the pause,asym_pauseand autoneg bits inpl->supported. Rather than reading the bits into separate bools, zeroingpl->supported, and then setting them if they were previously set, use a mask andlinkmode_and()to achieve the same result.Signed-off-by Russell King (Oracle) <[email protected]>
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Tue, 22 Oct 2024 15:17:07 +0100 you wrote:
phylink_parse_fixedlink()wants to preserve the pause,asym_pauseand autoneg bits inpl->supported. Rather than reading the bits into separate bools, zeroingpl->supported, and then setting them if they were previously set, use a mask andlinkmode_and()to achieve the same result.Signed-off-by Russell King (Oracle) <[email protected]>[...]
Here is the summary with links:
- [net-next] net: phylink: simplify phylink_parse_fixedlink()
https://git.kernel.org/netdev/net-next/c/e0e918494c3c
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html