mirror of
https://github.com/torvalds/linux.git
synced 2024-11-18 01:51:53 +00:00
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: Heiner Kallweit <hkallweit1@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
8b58d12f4a
commit
a2703de709
@ -421,45 +421,16 @@ void of_set_phy_eee_broken(struct phy_device *phydev)
|
|||||||
void phy_resolve_aneg_linkmode(struct phy_device *phydev)
|
void phy_resolve_aneg_linkmode(struct phy_device *phydev)
|
||||||
{
|
{
|
||||||
__ETHTOOL_DECLARE_LINK_MODE_MASK(common);
|
__ETHTOOL_DECLARE_LINK_MODE_MASK(common);
|
||||||
|
int i;
|
||||||
|
|
||||||
linkmode_and(common, phydev->lp_advertising, phydev->advertising);
|
linkmode_and(common, phydev->lp_advertising, phydev->advertising);
|
||||||
|
|
||||||
if (linkmode_test_bit(ETHTOOL_LINK_MODE_10000baseT_Full_BIT, common)) {
|
for (i = 0; i < ARRAY_SIZE(settings); i++)
|
||||||
phydev->speed = SPEED_10000;
|
if (test_bit(settings[i].bit, common)) {
|
||||||
phydev->duplex = DUPLEX_FULL;
|
phydev->speed = settings[i].speed;
|
||||||
} else if (linkmode_test_bit(ETHTOOL_LINK_MODE_5000baseT_Full_BIT,
|
phydev->duplex = settings[i].duplex;
|
||||||
common)) {
|
break;
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (phydev->duplex == DUPLEX_FULL) {
|
if (phydev->duplex == DUPLEX_FULL) {
|
||||||
phydev->pause = linkmode_test_bit(ETHTOOL_LINK_MODE_Pause_BIT,
|
phydev->pause = linkmode_test_bit(ETHTOOL_LINK_MODE_Pause_BIT,
|
||||||
|
Loading…
Reference in New Issue
Block a user