kernel: copy kernel 4.19 code to 5.4
[oweals/openwrt.git] / target / linux / generic / pending-5.4 / 744-net-sfp-move-phy_start-phy_stop-to-phylink.patch
1 From e2dc261b872a92a055eb2e86ac136baf9b20f2f2 Mon Sep 17 00:00:00 2001
2 From: Russell King <rmk+kernel@armlinux.org.uk>
3 Date: Thu, 21 Nov 2019 17:21:33 +0000
4 Subject: [PATCH 647/660] net: sfp: move phy_start()/phy_stop() to phylink
5
6 Move phy_start() and phy_stop() into the module_start and module_stop
7 notifications in phylink, rather than having them in the SFP code.
8 This gives phylink responsibility for controlling the PHY, rather
9 than having SFP start and stop the PHY state machine.
10
11 Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
12 ---
13  drivers/net/phy/phylink.c | 22 ++++++++++++++++++++++
14  drivers/net/phy/sfp.c     |  2 --
15  2 files changed, 22 insertions(+), 2 deletions(-)
16
17 --- a/drivers/net/phy/phylink.c
18 +++ b/drivers/net/phy/phylink.c
19 @@ -1717,6 +1717,26 @@ static int phylink_sfp_module_insert(voi
20         return ret;
21  }
22  
23 +static int phylink_sfp_module_start(void *upstream)
24 +{
25 +       struct phylink *pl = upstream;
26 +
27 +       /* If this SFP module has a PHY, start the PHY now. */
28 +       if (pl->phydev)
29 +               phy_start(pl->phydev);
30 +               
31 +       return 0;
32 +}
33 +
34 +static void phylink_sfp_module_stop(void *upstream)
35 +{
36 +       struct phylink *pl = upstream;
37 +
38 +       /* If this SFP module has a PHY, stop it. */
39 +       if (pl->phydev)
40 +               phy_stop(pl->phydev);
41 +}
42 +
43  static void phylink_sfp_link_down(void *upstream)
44  {
45         struct phylink *pl = upstream;
46 @@ -1752,6 +1772,8 @@ static const struct sfp_upstream_ops sfp
47         .attach = phylink_sfp_attach,
48         .detach = phylink_sfp_detach,
49         .module_insert = phylink_sfp_module_insert,
50 +       .module_start = phylink_sfp_module_start,
51 +       .module_stop = phylink_sfp_module_stop,
52         .link_up = phylink_sfp_link_up,
53         .link_down = phylink_sfp_link_down,
54         .connect_phy = phylink_sfp_connect_phy,
55 --- a/drivers/net/phy/sfp.c
56 +++ b/drivers/net/phy/sfp.c
57 @@ -1331,7 +1331,6 @@ static void sfp_sm_mod_next(struct sfp *
58  
59  static void sfp_sm_phy_detach(struct sfp *sfp)
60  {
61 -       phy_stop(sfp->mod_phy);
62         sfp_remove_phy(sfp->sfp_bus);
63         phy_device_remove(sfp->mod_phy);
64         phy_device_free(sfp->mod_phy);
65 @@ -1362,7 +1361,6 @@ static void sfp_sm_probe_phy(struct sfp
66         }
67  
68         sfp->mod_phy = phy;
69 -       phy_start(phy);
70  }
71  
72  static void sfp_sm_link_up(struct sfp *sfp)