kernel: m25p80: allow fallback from spi_flash_read to regular SPI transfer
[openwrt/openwrt.git] / target / linux / brcm63xx / patches-4.14 / 001-4.15-11-bcm63xx_enet-use-managed-functions-for-clock-ioremap.patch
1 From 179a445ae4ef36ec44f4aea18e5f42d21334d186 Mon Sep 17 00:00:00 2001
2 From: Jonas Gorski <jonas.gorski@gmail.com>
3 Date: Sat, 25 Feb 2017 12:39:25 +0100
4 Subject: [PATCH 4/6] bcm63xx_enet: use managed functions for clock/ioremap
5
6 Use managed functions where possible to reduce the amount of resource
7 handling on error and remove paths.
8
9 Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
10 ---
11 drivers/net/ethernet/broadcom/bcm63xx_enet.c | 54 +++++++---------------------
12 1 file changed, 12 insertions(+), 42 deletions(-)
13
14 --- a/drivers/net/ethernet/broadcom/bcm63xx_enet.c
15 +++ b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
16 @@ -1767,14 +1767,14 @@ static int bcm_enet_probe(struct platfor
17 clk_name = "enet1";
18 }
19
20 - priv->mac_clk = clk_get(&pdev->dev, clk_name);
21 + priv->mac_clk = devm_clk_get(&pdev->dev, clk_name);
22 if (IS_ERR(priv->mac_clk)) {
23 ret = PTR_ERR(priv->mac_clk);
24 goto out;
25 }
26 ret = clk_prepare_enable(priv->mac_clk);
27 if (ret)
28 - goto out_put_clk_mac;
29 + goto out;
30
31 /* initialize default and fetch platform data */
32 priv->rx_ring_size = BCMENET_DEF_RX_DESC;
33 @@ -1802,7 +1802,7 @@ static int bcm_enet_probe(struct platfor
34
35 if (priv->mac_id == 0 && priv->has_phy && !priv->use_external_mii) {
36 /* using internal PHY, enable clock */
37 - priv->phy_clk = clk_get(&pdev->dev, "ephy");
38 + priv->phy_clk = devm_clk_get(&pdev->dev, "ephy");
39 if (IS_ERR(priv->phy_clk)) {
40 ret = PTR_ERR(priv->phy_clk);
41 priv->phy_clk = NULL;
42 @@ -1810,7 +1810,7 @@ static int bcm_enet_probe(struct platfor
43 }
44 ret = clk_prepare_enable(priv->phy_clk);
45 if (ret)
46 - goto out_put_clk_phy;
47 + goto out_disable_clk_mac;
48 }
49
50 /* do minimal hardware init to be able to probe mii bus */
51 @@ -1907,14 +1907,8 @@ out_uninit_hw:
52 if (priv->phy_clk)
53 clk_disable_unprepare(priv->phy_clk);
54
55 -out_put_clk_phy:
56 - if (priv->phy_clk)
57 - clk_put(priv->phy_clk);
58 -
59 out_disable_clk_mac:
60 clk_disable_unprepare(priv->mac_clk);
61 -out_put_clk_mac:
62 - clk_put(priv->mac_clk);
63 out:
64 free_netdev(dev);
65 return ret;
66 @@ -1950,12 +1944,10 @@ static int bcm_enet_remove(struct platfo
67 }
68
69 /* disable hw block clocks */
70 - if (priv->phy_clk) {
71 + if (priv->phy_clk)
72 clk_disable_unprepare(priv->phy_clk);
73 - clk_put(priv->phy_clk);
74 - }
75 +
76 clk_disable_unprepare(priv->mac_clk);
77 - clk_put(priv->mac_clk);
78
79 free_netdev(dev);
80 return 0;
81 @@ -2738,26 +2730,20 @@ static int bcm_enetsw_probe(struct platf
82 if (ret)
83 goto out;
84
85 - if (!request_mem_region(res_mem->start, resource_size(res_mem),
86 - "bcm63xx_enetsw")) {
87 - ret = -EBUSY;
88 + priv->base = devm_ioremap_resource(&pdev->dev, res_mem);
89 + if (IS_ERR(priv->base)) {
90 + ret = PTR_ERR(priv->base);
91 goto out;
92 }
93
94 - priv->base = ioremap(res_mem->start, resource_size(res_mem));
95 - if (priv->base == NULL) {
96 - ret = -ENOMEM;
97 - goto out_release_mem;
98 - }
99 -
100 - priv->mac_clk = clk_get(&pdev->dev, "enetsw");
101 + priv->mac_clk = devm_clk_get(&pdev->dev, "enetsw");
102 if (IS_ERR(priv->mac_clk)) {
103 ret = PTR_ERR(priv->mac_clk);
104 - goto out_unmap;
105 + goto out;
106 }
107 ret = clk_prepare_enable(priv->mac_clk);
108 if (ret)
109 - goto out_put_clk;
110 + goto out;
111
112 priv->rx_chan = 0;
113 priv->tx_chan = 1;
114 @@ -2789,15 +2775,6 @@ static int bcm_enetsw_probe(struct platf
115
116 out_disable_clk:
117 clk_disable_unprepare(priv->mac_clk);
118 -
119 -out_put_clk:
120 - clk_put(priv->mac_clk);
121 -
122 -out_unmap:
123 - iounmap(priv->base);
124 -
125 -out_release_mem:
126 - release_mem_region(res_mem->start, resource_size(res_mem));
127 out:
128 free_netdev(dev);
129 return ret;
130 @@ -2809,20 +2786,13 @@ static int bcm_enetsw_remove(struct plat
131 {
132 struct bcm_enet_priv *priv;
133 struct net_device *dev;
134 - struct resource *res;
135
136 /* stop netdevice */
137 dev = platform_get_drvdata(pdev);
138 priv = netdev_priv(dev);
139 unregister_netdev(dev);
140
141 - /* release device resources */
142 - iounmap(priv->base);
143 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
144 - release_mem_region(res->start, resource_size(res));
145 -
146 clk_disable_unprepare(priv->mac_clk);
147 - clk_put(priv->mac_clk);
148
149 free_netdev(dev);
150 return 0;