2
0

716-v6.9-06-net-phy-provide-whether-link-has-changed-in-c37_read.patch 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. From 9b1d5e055508393561e26bd1720f4c2639b03b1a Mon Sep 17 00:00:00 2001
  2. From: Christian Marangi <[email protected]>
  3. Date: Tue, 6 Feb 2024 18:31:09 +0100
  4. Subject: [PATCH 06/10] net: phy: provide whether link has changed in
  5. c37_read_status
  6. Some PHY driver might require additional regs call after
  7. genphy_c37_read_status() is called.
  8. Expand genphy_c37_read_status to provide a bool wheather the link has
  9. changed or not to permit PHY driver to skip additional regs call if
  10. nothing has changed.
  11. Every user of genphy_c37_read_status() is updated with the new
  12. additional bool.
  13. Signed-off-by: Christian Marangi <[email protected]>
  14. Reviewed-by: Andrew Lunn <[email protected]>
  15. Signed-off-by: David S. Miller <[email protected]>
  16. ---
  17. drivers/net/phy/broadcom.c | 3 ++-
  18. drivers/net/phy/phy_device.c | 11 +++++++++--
  19. drivers/net/phy/qcom/at803x.c | 3 ++-
  20. include/linux/phy.h | 2 +-
  21. 4 files changed, 14 insertions(+), 5 deletions(-)
  22. --- a/drivers/net/phy/broadcom.c
  23. +++ b/drivers/net/phy/broadcom.c
  24. @@ -665,10 +665,11 @@ static int bcm54616s_config_aneg(struct
  25. static int bcm54616s_read_status(struct phy_device *phydev)
  26. {
  27. struct bcm54616s_phy_priv *priv = phydev->priv;
  28. + bool changed;
  29. int err;
  30. if (priv->mode_1000bx_en)
  31. - err = genphy_c37_read_status(phydev);
  32. + err = genphy_c37_read_status(phydev, &changed);
  33. else
  34. err = genphy_read_status(phydev);
  35. --- a/drivers/net/phy/phy_device.c
  36. +++ b/drivers/net/phy/phy_device.c
  37. @@ -2607,12 +2607,15 @@ EXPORT_SYMBOL(genphy_read_status);
  38. /**
  39. * genphy_c37_read_status - check the link status and update current link state
  40. * @phydev: target phy_device struct
  41. + * @changed: pointer where to store if link changed
  42. *
  43. * Description: Check the link, then figure out the current state
  44. * by comparing what we advertise with what the link partner
  45. * advertises. This function is for Clause 37 1000Base-X mode.
  46. + *
  47. + * If link has changed, @changed is set to true, false otherwise.
  48. */
  49. -int genphy_c37_read_status(struct phy_device *phydev)
  50. +int genphy_c37_read_status(struct phy_device *phydev, bool *changed)
  51. {
  52. int lpa, err, old_link = phydev->link;
  53. @@ -2622,9 +2625,13 @@ int genphy_c37_read_status(struct phy_de
  54. return err;
  55. /* why bother the PHY if nothing can have changed */
  56. - if (phydev->autoneg == AUTONEG_ENABLE && old_link && phydev->link)
  57. + if (phydev->autoneg == AUTONEG_ENABLE && old_link && phydev->link) {
  58. + *changed = false;
  59. return 0;
  60. + }
  61. + /* Signal link has changed */
  62. + *changed = true;
  63. phydev->duplex = DUPLEX_UNKNOWN;
  64. phydev->pause = 0;
  65. phydev->asym_pause = 0;
  66. --- a/drivers/net/phy/qcom/at803x.c
  67. +++ b/drivers/net/phy/qcom/at803x.c
  68. @@ -912,9 +912,10 @@ static int at8031_config_intr(struct phy
  69. static int at8031_read_status(struct phy_device *phydev)
  70. {
  71. struct at803x_priv *priv = phydev->priv;
  72. + bool changed;
  73. if (priv->is_1000basex)
  74. - return genphy_c37_read_status(phydev);
  75. + return genphy_c37_read_status(phydev, &changed);
  76. return at803x_read_status(phydev);
  77. }
  78. --- a/include/linux/phy.h
  79. +++ b/include/linux/phy.h
  80. @@ -1849,7 +1849,7 @@ int genphy_write_mmd_unsupported(struct
  81. /* Clause 37 */
  82. int genphy_c37_config_aneg(struct phy_device *phydev);
  83. -int genphy_c37_read_status(struct phy_device *phydev);
  84. +int genphy_c37_read_status(struct phy_device *phydev, bool *changed);
  85. /* Clause 45 PHY */
  86. int genphy_c45_restart_aneg(struct phy_device *phydev);