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