Skip to content

Commit

Permalink
net: phy: Make use of linkmode_mod_bit helper
Browse files Browse the repository at this point in the history
linkmode_mod_bit is introduced as a helper function to set/clear
bits in a linkmode.
Replace the if else code structure with a call to the helper
linkmode_mod_bit.

Signed-off-by: Fuqian Huang <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Yellow-Pay authored and davem330 committed Jul 9, 2019
1 parent 88e2f28 commit ccf355e
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions drivers/net/phy/phy.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,12 +298,8 @@ int phy_ethtool_sset(struct phy_device *phydev, struct ethtool_cmd *cmd)

linkmode_copy(phydev->advertising, advertising);

if (AUTONEG_ENABLE == cmd->autoneg)
linkmode_set_bit(ETHTOOL_LINK_MODE_Autoneg_BIT,
phydev->advertising);
else
linkmode_clear_bit(ETHTOOL_LINK_MODE_Autoneg_BIT,
phydev->advertising);
linkmode_mod_bit(ETHTOOL_LINK_MODE_Autoneg_BIT,
phydev->advertising, AUTONEG_ENABLE == cmd->autoneg);

phydev->duplex = cmd->duplex;

Expand Down Expand Up @@ -353,12 +349,8 @@ int phy_ethtool_ksettings_set(struct phy_device *phydev,

linkmode_copy(phydev->advertising, advertising);

if (autoneg == AUTONEG_ENABLE)
linkmode_set_bit(ETHTOOL_LINK_MODE_Autoneg_BIT,
phydev->advertising);
else
linkmode_clear_bit(ETHTOOL_LINK_MODE_Autoneg_BIT,
phydev->advertising);
linkmode_mod_bit(ETHTOOL_LINK_MODE_Autoneg_BIT,
phydev->advertising, autoneg == AUTONEG_ENABLE);

phydev->duplex = duplex;

Expand Down

0 comments on commit ccf355e

Please sign in to comment.