Commit 8b68710a authored by Oleksij Rempel's avatar Oleksij Rempel Committed by David S. Miller

net: phy: start using genphy_c45_ethtool_get/set_eee()

All preparations are done. Now we can start using new functions and remove
the old code.
Signed-off-by: default avatarOleksij Rempel <o.rempel@pengutronix.de>
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 6340f9fd
...@@ -1517,33 +1517,10 @@ EXPORT_SYMBOL(phy_get_eee_err); ...@@ -1517,33 +1517,10 @@ EXPORT_SYMBOL(phy_get_eee_err);
*/ */
int phy_ethtool_get_eee(struct phy_device *phydev, struct ethtool_eee *data) int phy_ethtool_get_eee(struct phy_device *phydev, struct ethtool_eee *data)
{ {
int val;
if (!phydev->drv) if (!phydev->drv)
return -EIO; return -EIO;
/* Get Supported EEE */ return genphy_c45_ethtool_get_eee(phydev, data);
val = phy_read_mmd(phydev, MDIO_MMD_PCS, MDIO_PCS_EEE_ABLE);
if (val < 0)
return val;
data->supported = mmd_eee_cap_to_ethtool_sup_t(val);
/* Get advertisement EEE */
val = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_EEE_ADV);
if (val < 0)
return val;
data->advertised = mmd_eee_adv_to_ethtool_adv_t(val);
data->eee_enabled = !!data->advertised;
/* Get LP advertisement EEE */
val = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_EEE_LPABLE);
if (val < 0)
return val;
data->lp_advertised = mmd_eee_adv_to_ethtool_adv_t(val);
data->eee_active = !!(data->advertised & data->lp_advertised);
return 0;
} }
EXPORT_SYMBOL(phy_ethtool_get_eee); EXPORT_SYMBOL(phy_ethtool_get_eee);
...@@ -1556,43 +1533,10 @@ EXPORT_SYMBOL(phy_ethtool_get_eee); ...@@ -1556,43 +1533,10 @@ EXPORT_SYMBOL(phy_ethtool_get_eee);
*/ */
int phy_ethtool_set_eee(struct phy_device *phydev, struct ethtool_eee *data) int phy_ethtool_set_eee(struct phy_device *phydev, struct ethtool_eee *data)
{ {
int cap, old_adv, adv = 0, ret;
if (!phydev->drv) if (!phydev->drv)
return -EIO; return -EIO;
/* Get Supported EEE */ return genphy_c45_ethtool_set_eee(phydev, data);
cap = phy_read_mmd(phydev, MDIO_MMD_PCS, MDIO_PCS_EEE_ABLE);
if (cap < 0)
return cap;
old_adv = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_EEE_ADV);
if (old_adv < 0)
return old_adv;
if (data->eee_enabled) {
adv = !data->advertised ? cap :
ethtool_adv_to_mmd_eee_adv_t(data->advertised) & cap;
/* Mask prohibited EEE modes */
adv &= ~phydev->eee_broken_modes;
}
if (old_adv != adv) {
ret = phy_write_mmd(phydev, MDIO_MMD_AN, MDIO_AN_EEE_ADV, adv);
if (ret < 0)
return ret;
/* Restart autonegotiation so the new modes get sent to the
* link partner.
*/
if (phydev->autoneg == AUTONEG_ENABLE) {
ret = phy_restart_aneg(phydev);
if (ret < 0)
return ret;
}
}
return 0;
} }
EXPORT_SYMBOL(phy_ethtool_set_eee); EXPORT_SYMBOL(phy_ethtool_set_eee);
......
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