720-Revert-net-phy-simplify-phy_link_change-arguments.patch 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. From ffbb1b37a3e1ce1a5c574a6bd4f5aede8bc468ac Mon Sep 17 00:00:00 2001
  2. From: Ilya Lipnitskiy <[email protected]>
  3. Date: Sat, 27 Feb 2021 20:20:07 -0800
  4. Subject: [PATCH] Revert "net: phy: simplify phy_link_change arguments"
  5. This reverts commit a307593a644443db12888f45eed0dafb5869e2cc.
  6. This brings back the do_carrier flags used by the (hacky) next patch,
  7. still required by target/linux/ramips/files/drivers/net/ethernet/ralink/mdio.c
  8. ---
  9. drivers/net/phy/phy.c | 12 ++++++------
  10. drivers/net/phy/phy_device.c | 12 +++++++-----
  11. drivers/net/phy/phylink.c | 3 ++-
  12. include/linux/phy.h | 2 +-
  13. 4 files changed, 16 insertions(+), 13 deletions(-)
  14. --- a/drivers/net/phy/phy.c
  15. +++ b/drivers/net/phy/phy.c
  16. @@ -72,13 +72,13 @@ static void phy_process_state_change(str
  17. static void phy_link_up(struct phy_device *phydev)
  18. {
  19. - phydev->phy_link_change(phydev, true);
  20. + phydev->phy_link_change(phydev, true, true);
  21. phy_led_trigger_change_speed(phydev);
  22. }
  23. -static void phy_link_down(struct phy_device *phydev)
  24. +static void phy_link_down(struct phy_device *phydev, bool do_carrier)
  25. {
  26. - phydev->phy_link_change(phydev, false);
  27. + phydev->phy_link_change(phydev, false, do_carrier);
  28. phy_led_trigger_change_speed(phydev);
  29. WRITE_ONCE(phydev->link_down_events, phydev->link_down_events + 1);
  30. }
  31. @@ -823,7 +823,7 @@ int phy_start_cable_test(struct phy_devi
  32. goto out;
  33. /* Mark the carrier down until the test is complete */
  34. - phy_link_down(phydev);
  35. + phy_link_down(phydev, true);
  36. netif_testing_on(dev);
  37. err = phydev->drv->cable_test_start(phydev);
  38. @@ -894,7 +894,7 @@ int phy_start_cable_test_tdr(struct phy_
  39. goto out;
  40. /* Mark the carrier down until the test is complete */
  41. - phy_link_down(phydev);
  42. + phy_link_down(phydev, true);
  43. netif_testing_on(dev);
  44. err = phydev->drv->cable_test_tdr_start(phydev, config);
  45. @@ -966,7 +966,7 @@ static int phy_check_link_status(struct
  46. phy_link_up(phydev);
  47. } else if (!phydev->link && phydev->state != PHY_NOLINK) {
  48. phydev->state = PHY_NOLINK;
  49. - phy_link_down(phydev);
  50. + phy_link_down(phydev, true);
  51. }
  52. return 0;
  53. @@ -1485,7 +1485,7 @@ void phy_state_machine(struct work_struc
  54. case PHY_ERROR:
  55. if (phydev->link) {
  56. phydev->link = 0;
  57. - phy_link_down(phydev);
  58. + phy_link_down(phydev, true);
  59. }
  60. do_suspend = true;
  61. break;
  62. --- a/drivers/net/phy/phy_device.c
  63. +++ b/drivers/net/phy/phy_device.c
  64. @@ -1069,14 +1069,16 @@ struct phy_device *phy_find_first(struct
  65. }
  66. EXPORT_SYMBOL(phy_find_first);
  67. -static void phy_link_change(struct phy_device *phydev, bool up)
  68. +static void phy_link_change(struct phy_device *phydev, bool up, bool do_carrier)
  69. {
  70. struct net_device *netdev = phydev->attached_dev;
  71. - if (up)
  72. - netif_carrier_on(netdev);
  73. - else
  74. - netif_carrier_off(netdev);
  75. + if (do_carrier) {
  76. + if (up)
  77. + netif_carrier_on(netdev);
  78. + else
  79. + netif_carrier_off(netdev);
  80. + }
  81. phydev->adjust_link(netdev);
  82. if (phydev->mii_ts && phydev->mii_ts->link_state)
  83. phydev->mii_ts->link_state(phydev->mii_ts, phydev);
  84. --- a/drivers/net/phy/phylink.c
  85. +++ b/drivers/net/phy/phylink.c
  86. @@ -1724,7 +1724,8 @@ bool phylink_expects_phy(struct phylink
  87. }
  88. EXPORT_SYMBOL_GPL(phylink_expects_phy);
  89. -static void phylink_phy_change(struct phy_device *phydev, bool up)
  90. +static void phylink_phy_change(struct phy_device *phydev, bool up,
  91. + bool do_carrier)
  92. {
  93. struct phylink *pl = phydev->phylink;
  94. bool tx_pause, rx_pause;
  95. --- a/include/linux/phy.h
  96. +++ b/include/linux/phy.h
  97. @@ -758,7 +758,7 @@ struct phy_device {
  98. unsigned int link_down_events;
  99. - void (*phy_link_change)(struct phy_device *phydev, bool up);
  100. + void (*phy_link_change)(struct phy_device *, bool up, bool do_carrier);
  101. void (*adjust_link)(struct net_device *dev);
  102. #if IS_ENABLED(CONFIG_MACSEC)