Merge branch 'net-phy-improve-and-use-phy_resolve_aneg_linkmode'

Heiner Kallweit says:

====================
net: phy: improve and use phy_resolve_aneg_linkmode

Improve phy_resolve_aneg_linkmode and use it in genphy_read_status.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
David S. Miller 2019-02-17 15:21:39 -08:00
Родитель 8b58d12f4a 5502b218e0
Коммит 8e31c47424
2 изменённых файлов: 8 добавлений и 59 удалений

Просмотреть файл

@ -421,45 +421,16 @@ 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) {
phydev->pause = linkmode_test_bit(ETHTOOL_LINK_MODE_Pause_BIT,

Просмотреть файл

@ -1746,8 +1746,6 @@ int genphy_read_status(struct phy_device *phydev)
int err;
int lpa;
int lpagb = 0;
int common_adv;
int common_adv_gb = 0;
/* Update the link, but return if there was an error */
err = genphy_update_link(phydev);
@ -1779,7 +1777,6 @@ int genphy_read_status(struct phy_device *phydev)
mii_stat1000_mod_linkmode_lpa_t(phydev->lp_advertising,
lpagb);
common_adv_gb = lpagb & adv << 2;
}
lpa = phy_read(phydev, MII_LPA);
@ -1792,31 +1789,12 @@ int genphy_read_status(struct phy_device *phydev)
if (adv < 0)
return adv;
common_adv = lpa & adv;
phydev->speed = SPEED_10;
phydev->duplex = DUPLEX_HALF;
phydev->pause = 0;
phydev->asym_pause = 0;
if (common_adv_gb & (LPA_1000FULL | LPA_1000HALF)) {
phydev->speed = SPEED_1000;
if (common_adv_gb & LPA_1000FULL)
phydev->duplex = DUPLEX_FULL;
} else if (common_adv & (LPA_100FULL | LPA_100HALF)) {
phydev->speed = SPEED_100;
if (common_adv & LPA_100FULL)
phydev->duplex = DUPLEX_FULL;
} else
if (common_adv & LPA_10FULL)
phydev->duplex = DUPLEX_FULL;
if (phydev->duplex == DUPLEX_FULL) {
phydev->pause = lpa & LPA_PAUSE_CAP ? 1 : 0;
phydev->asym_pause = lpa & LPA_PAUSE_ASYM ? 1 : 0;
}
phy_resolve_aneg_linkmode(phydev);
} else {
int bmcr = phy_read(phydev, MII_BMCR);