Commit a2703de7 authored by Heiner Kallweit's avatar Heiner Kallweit Committed by David S. Miller

net: phy: improve phy_resolve_aneg_linkmode

We have the settings array of modes which is sorted based on aneg
priority. Instead of checking each mode manually let's simply iterate
over the sorted settings.
Signed-off-by: default avatarHeiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 8b58d12f
......@@ -421,44 +421,15 @@ void of_set_phy_eee_broken(struct phy_device *phydev)
void phy_resolve_aneg_linkmode(struct phy_device *phydev)
{
__ETHTOOL_DECLARE_LINK_MODE_MASK(common);
int i;
linkmode_and(common, phydev->lp_advertising, phydev->advertising);
if (linkmode_test_bit(ETHTOOL_LINK_MODE_10000baseT_Full_BIT, common)) {
phydev->speed = SPEED_10000;
phydev->duplex = DUPLEX_FULL;
} else if (linkmode_test_bit(ETHTOOL_LINK_MODE_5000baseT_Full_BIT,
common)) {
phydev->speed = SPEED_5000;
phydev->duplex = DUPLEX_FULL;
} else if (linkmode_test_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT,
common)) {
phydev->speed = SPEED_2500;
phydev->duplex = DUPLEX_FULL;
} else if (linkmode_test_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT,
common)) {
phydev->speed = SPEED_1000;
phydev->duplex = DUPLEX_FULL;
} else if (linkmode_test_bit(ETHTOOL_LINK_MODE_1000baseT_Half_BIT,
common)) {
phydev->speed = SPEED_1000;
phydev->duplex = DUPLEX_HALF;
} else if (linkmode_test_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT,
common)) {
phydev->speed = SPEED_100;
phydev->duplex = DUPLEX_FULL;
} else if (linkmode_test_bit(ETHTOOL_LINK_MODE_100baseT_Half_BIT,
common)) {
phydev->speed = SPEED_100;
phydev->duplex = DUPLEX_HALF;
} else if (linkmode_test_bit(ETHTOOL_LINK_MODE_10baseT_Full_BIT,
common)) {
phydev->speed = SPEED_10;
phydev->duplex = DUPLEX_FULL;
} else if (linkmode_test_bit(ETHTOOL_LINK_MODE_10baseT_Half_BIT,
common)) {
phydev->speed = SPEED_10;
phydev->duplex = DUPLEX_HALF;
for (i = 0; i < ARRAY_SIZE(settings); i++)
if (test_bit(settings[i].bit, common)) {
phydev->speed = settings[i].speed;
phydev->duplex = settings[i].duplex;
break;
}
if (phydev->duplex == DUPLEX_FULL) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment