1 From: Russell King <rmk+kernel@armlinux.org.uk>
2 Date: Thu, 5 Jan 2017 12:21:09 +0000
3 Subject: [PATCH] net: phy: restart phy autonegotiation after EEE
6 When the EEE advertisment is changed, we should restart autonegotiation
7 to update the link partner with the new EEE settings. Add this trigger
8 but only if the advertisment has changed.
10 Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
13 --- a/drivers/net/phy/phy.c
14 +++ b/drivers/net/phy/phy.c
15 @@ -1307,16 +1307,33 @@ EXPORT_SYMBOL(phy_ethtool_get_eee);
17 int phy_ethtool_set_eee(struct phy_device *phydev, struct ethtool_eee *data)
20 + int cap, old_adv, adv, ret;
22 /* Get Supported EEE */
23 cap = phy_read_mmd(phydev, MDIO_MMD_PCS, MDIO_PCS_EEE_ABLE);
27 + old_adv = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_EEE_ADV);
31 adv = ethtool_adv_to_mmd_eee_adv_t(data->advertised) & cap;
33 - return phy_write_mmd(phydev, MDIO_MMD_AN, MDIO_AN_EEE_ADV, adv);
34 + if (old_adv != adv) {
35 + ret = phy_write_mmd(phydev, MDIO_MMD_AN, MDIO_AN_EEE_ADV, adv);
39 + /* Restart autonegotiation so the new modes get sent to the
42 + ret = phy_restart_aneg(phydev);
49 EXPORT_SYMBOL(phy_ethtool_set_eee);