408-net-phy-hook-up-clause-45-autonegotiation-restart.patch 1.4 KB

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