kernel: update kernel 4.9 to 4.9.37
[openwrt/staging/chunkeey.git] / target / linux / mvebu / patches-4.9 / 408-net-phy-hook-up-clause-45-autonegotiation-restart.patch
1 From: Russell King <rmk+kernel@armlinux.org.uk>
2 Date: Fri, 13 Jan 2017 11:17:30 +0000
3 Subject: [PATCH] net: phy: hook up clause 45 autonegotiation restart
4
5 genphy_restart_aneg() can only restart autonegotiation on clause 22
6 PHYs. Add a phy_restart_aneg() function which selects between the
7 clause 22 and clause 45 restart functionality depending on the PHY
8 type.
9
10 Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
11 ---
12
13 --- a/drivers/net/phy/phy.c
14 +++ b/drivers/net/phy/phy.c
15 @@ -134,6 +134,24 @@ static int phy_config_interrupt(struct p
16 return 0;
17 }
18
19 +/**
20 + * phy_restart_aneg - restart auto-negotiation
21 + * @phydev: target phy_device struct
22 + *
23 + * Restart the autonegotiation on @phydev. Returns >= 0 on success or
24 + * negative errno on error.
25 + */
26 +static int phy_restart_aneg(struct phy_device *phydev)
27 +{
28 + int ret;
29 +
30 + if (phydev->is_c45)
31 + ret = genphy_c45_restart_aneg(phydev);
32 + else
33 + ret = genphy_restart_aneg(phydev);
34 +
35 + return ret;
36 +}
37
38 /**
39 * phy_aneg_done - return auto-negotiation status
40 @@ -1442,3 +1460,14 @@ int phy_ethtool_set_link_ksettings(struc
41 return phy_ethtool_ksettings_set(phydev, cmd);
42 }
43 EXPORT_SYMBOL(phy_ethtool_set_link_ksettings);
44 +
45 +int phy_ethtool_nway_reset(struct net_device *ndev)
46 +{
47 + struct phy_device *phydev = ndev->phydev;
48 +
49 + if (!phydev)
50 + return -ENODEV;
51 +
52 + return phy_restart_aneg(phydev);
53 +}
54 +EXPORT_SYMBOL(phy_ethtool_nway_reset);