ath79: ar7242: Update dts for current ag71xx driver
[oweals/openwrt.git] / target / linux / brcm63xx / patches-4.9 / 001-4.15-08-bcm63xx_enet-correct-clock-usage.patch
1 From d0423d3e4fa7ae305729cb50369427f075ccb279 Mon Sep 17 00:00:00 2001
2 From: Jonas Gorski <jonas.gorski@gmail.com>
3 Date: Sat, 25 Feb 2017 12:41:28 +0100
4 Subject: [PATCH 1/6] bcm63xx_enet: correct clock usage
5
6 Check the return code of prepare_enable and change one last instance of
7 enable only to prepare_enable. Also properly disable and release the
8 clock in error paths and on remove for enetsw.
9
10 Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
11 ---
12  drivers/net/ethernet/broadcom/bcm63xx_enet.c | 31 +++++++++++++++++++++-------
13  1 file changed, 23 insertions(+), 8 deletions(-)
14
15 --- a/drivers/net/ethernet/broadcom/bcm63xx_enet.c
16 +++ b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
17 @@ -1790,7 +1790,9 @@ static int bcm_enet_probe(struct platfor
18                 ret = PTR_ERR(priv->mac_clk);
19                 goto out;
20         }
21 -       clk_prepare_enable(priv->mac_clk);
22 +       ret = clk_prepare_enable(priv->mac_clk);
23 +       if (ret)
24 +               goto out_put_clk_mac;
25  
26         /* initialize default and fetch platform data */
27         priv->rx_ring_size = BCMENET_DEF_RX_DESC;
28 @@ -1822,9 +1824,11 @@ static int bcm_enet_probe(struct platfor
29                 if (IS_ERR(priv->phy_clk)) {
30                         ret = PTR_ERR(priv->phy_clk);
31                         priv->phy_clk = NULL;
32 -                       goto out_put_clk_mac;
33 +                       goto out_disable_clk_mac;
34                 }
35 -               clk_prepare_enable(priv->phy_clk);
36 +               ret = clk_prepare_enable(priv->phy_clk);
37 +               if (ret)
38 +                       goto out_put_clk_phy;
39         }
40  
41         /* do minimal hardware init to be able to probe mii bus */
42 @@ -1915,13 +1919,16 @@ out_free_mdio:
43  out_uninit_hw:
44         /* turn off mdc clock */
45         enet_writel(priv, 0, ENET_MIISC_REG);
46 -       if (priv->phy_clk) {
47 +       if (priv->phy_clk)
48                 clk_disable_unprepare(priv->phy_clk);
49 +
50 +out_put_clk_phy:
51 +       if (priv->phy_clk)
52                 clk_put(priv->phy_clk);
53 -       }
54  
55 -out_put_clk_mac:
56 +out_disable_clk_mac:
57         clk_disable_unprepare(priv->mac_clk);
58 +out_put_clk_mac:
59         clk_put(priv->mac_clk);
60  out:
61         free_netdev(dev);
62 @@ -2766,7 +2773,9 @@ static int bcm_enetsw_probe(struct platf
63                 ret = PTR_ERR(priv->mac_clk);
64                 goto out_unmap;
65         }
66 -       clk_enable(priv->mac_clk);
67 +       ret = clk_prepare_enable(priv->mac_clk);
68 +       if (ret)
69 +               goto out_put_clk;
70  
71         priv->rx_chan = 0;
72         priv->tx_chan = 1;
73 @@ -2787,7 +2796,7 @@ static int bcm_enetsw_probe(struct platf
74  
75         ret = register_netdev(dev);
76         if (ret)
77 -               goto out_put_clk;
78 +               goto out_disable_clk;
79  
80         netif_carrier_off(dev);
81         platform_set_drvdata(pdev, dev);
82 @@ -2796,6 +2805,9 @@ static int bcm_enetsw_probe(struct platf
83  
84         return 0;
85  
86 +out_disable_clk:
87 +       clk_disable_unprepare(priv->mac_clk);
88 +
89  out_put_clk:
90         clk_put(priv->mac_clk);
91  
92 @@ -2827,6 +2839,9 @@ static int bcm_enetsw_remove(struct plat
93         res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
94         release_mem_region(res->start, resource_size(res));
95  
96 +       clk_disable_unprepare(priv->mac_clk);
97 +       clk_put(priv->mac_clk);
98 +
99         free_netdev(dev);
100         return 0;
101  }