702-phy_add_aneg_done_function.patch 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. --- a/include/linux/phy.h
  2. +++ b/include/linux/phy.h
  3. @@ -417,9 +417,18 @@ struct phy_driver {
  4. */
  5. int (*config_aneg)(struct phy_device *phydev);
  6. + /* Determine if autonegotiation is done */
  7. + int (*aneg_done)(struct phy_device *phydev);
  8. +
  9. /* Determines the negotiated speed and duplex */
  10. int (*read_status)(struct phy_device *phydev);
  11. + /*
  12. + * Update the value in phydev->link to reflect the
  13. + * current link value
  14. + */
  15. + int (*update_link)(struct phy_device *phydev);
  16. +
  17. /* Clears any pending interrupts */
  18. int (*ack_interrupt)(struct phy_device *phydev);
  19. --- a/drivers/net/phy/phy_device.c
  20. +++ b/drivers/net/phy/phy_device.c
  21. @@ -881,6 +881,9 @@ int genphy_update_link(struct phy_device
  22. {
  23. int status;
  24. + if (phydev->drv->update_link)
  25. + return phydev->drv->update_link(phydev);
  26. +
  27. /* Do a fake read */
  28. status = phy_read(phydev, MII_BMSR);
  29. if (status < 0)
  30. --- a/drivers/net/phy/phy.c
  31. +++ b/drivers/net/phy/phy.c
  32. @@ -99,7 +99,12 @@ static int phy_config_interrupt(struct p
  33. */
  34. static inline int phy_aneg_done(struct phy_device *phydev)
  35. {
  36. - int retval = phy_read(phydev, MII_BMSR);
  37. + int retval;
  38. +
  39. + if (phydev->drv->aneg_done)
  40. + return phydev->drv->aneg_done(phydev);
  41. +
  42. + retval = phy_read(phydev, MII_BMSR);
  43. return (retval < 0) ? retval : (retval & BMSR_ANEGCOMPLETE);
  44. }