diff options
author | Srinivas Kandagatla <srinivas.kandagatla@st.com> | 2012-08-30 01:51:09 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-08-31 16:11:37 -0400 |
commit | 3f8bdecd32ab8f52bff1d646e2acb7c241d12a8d (patch) | |
tree | 634c4bb232cfba0c6fab663b1f707fb0985b97d8 /drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | |
parent | d56631a66c0d0c9d662abfb38cd1f6326eeebd7c (diff) |
net:stmmac: convert driver to use devm_request_and_ioremap.
This patch moves calls to ioremap and request_mem_region to
devm_request_and_ioremap call.
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@st.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c')
-rw-r--r-- | drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 40 |
1 files changed, 8 insertions, 32 deletions
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c index b4ffdc7ba4fc..ed112b55ae7f 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | |||
@@ -78,6 +78,7 @@ static int __devinit stmmac_pltfr_probe(struct platform_device *pdev) | |||
78 | { | 78 | { |
79 | int ret = 0; | 79 | int ret = 0; |
80 | struct resource *res; | 80 | struct resource *res; |
81 | struct device *dev = &pdev->dev; | ||
81 | void __iomem *addr = NULL; | 82 | void __iomem *addr = NULL; |
82 | struct stmmac_priv *priv = NULL; | 83 | struct stmmac_priv *priv = NULL; |
83 | struct plat_stmmacenet_data *plat_dat = NULL; | 84 | struct plat_stmmacenet_data *plat_dat = NULL; |
@@ -87,18 +88,10 @@ static int __devinit stmmac_pltfr_probe(struct platform_device *pdev) | |||
87 | if (!res) | 88 | if (!res) |
88 | return -ENODEV; | 89 | return -ENODEV; |
89 | 90 | ||
90 | if (!request_mem_region(res->start, resource_size(res), pdev->name)) { | 91 | addr = devm_request_and_ioremap(dev, res); |
91 | pr_err("%s: ERROR: memory allocation failed" | ||
92 | "cannot get the I/O addr 0x%x\n", | ||
93 | __func__, (unsigned int)res->start); | ||
94 | return -EBUSY; | ||
95 | } | ||
96 | |||
97 | addr = ioremap(res->start, resource_size(res)); | ||
98 | if (!addr) { | 92 | if (!addr) { |
99 | pr_err("%s: ERROR: memory mapping failed", __func__); | 93 | pr_err("%s: ERROR: memory mapping failed", __func__); |
100 | ret = -ENOMEM; | 94 | return -ENOMEM; |
101 | goto out_release_region; | ||
102 | } | 95 | } |
103 | 96 | ||
104 | if (pdev->dev.of_node) { | 97 | if (pdev->dev.of_node) { |
@@ -107,14 +100,13 @@ static int __devinit stmmac_pltfr_probe(struct platform_device *pdev) | |||
107 | GFP_KERNEL); | 100 | GFP_KERNEL); |
108 | if (!plat_dat) { | 101 | if (!plat_dat) { |
109 | pr_err("%s: ERROR: no memory", __func__); | 102 | pr_err("%s: ERROR: no memory", __func__); |
110 | ret = -ENOMEM; | 103 | return -ENOMEM; |
111 | goto out_unmap; | ||
112 | } | 104 | } |
113 | 105 | ||
114 | ret = stmmac_probe_config_dt(pdev, plat_dat, &mac); | 106 | ret = stmmac_probe_config_dt(pdev, plat_dat, &mac); |
115 | if (ret) { | 107 | if (ret) { |
116 | pr_err("%s: main dt probe failed", __func__); | 108 | pr_err("%s: main dt probe failed", __func__); |
117 | goto out_unmap; | 109 | return ret; |
118 | } | 110 | } |
119 | } else { | 111 | } else { |
120 | plat_dat = pdev->dev.platform_data; | 112 | plat_dat = pdev->dev.platform_data; |
@@ -124,13 +116,13 @@ static int __devinit stmmac_pltfr_probe(struct platform_device *pdev) | |||
124 | if (plat_dat->init) { | 116 | if (plat_dat->init) { |
125 | ret = plat_dat->init(pdev); | 117 | ret = plat_dat->init(pdev); |
126 | if (unlikely(ret)) | 118 | if (unlikely(ret)) |
127 | goto out_unmap; | 119 | return ret; |
128 | } | 120 | } |
129 | 121 | ||
130 | priv = stmmac_dvr_probe(&(pdev->dev), plat_dat, addr); | 122 | priv = stmmac_dvr_probe(&(pdev->dev), plat_dat, addr); |
131 | if (!priv) { | 123 | if (!priv) { |
132 | pr_err("%s: main driver probe failed", __func__); | 124 | pr_err("%s: main driver probe failed", __func__); |
133 | goto out_unmap; | 125 | return -ENODEV; |
134 | } | 126 | } |
135 | 127 | ||
136 | /* Get MAC address if available (DT) */ | 128 | /* Get MAC address if available (DT) */ |
@@ -142,8 +134,7 @@ static int __devinit stmmac_pltfr_probe(struct platform_device *pdev) | |||
142 | if (priv->dev->irq == -ENXIO) { | 134 | if (priv->dev->irq == -ENXIO) { |
143 | pr_err("%s: ERROR: MAC IRQ configuration " | 135 | pr_err("%s: ERROR: MAC IRQ configuration " |
144 | "information not found\n", __func__); | 136 | "information not found\n", __func__); |
145 | ret = -ENXIO; | 137 | return -ENXIO; |
146 | goto out_unmap; | ||
147 | } | 138 | } |
148 | 139 | ||
149 | /* | 140 | /* |
@@ -165,15 +156,6 @@ static int __devinit stmmac_pltfr_probe(struct platform_device *pdev) | |||
165 | pr_debug("STMMAC platform driver registration completed"); | 156 | pr_debug("STMMAC platform driver registration completed"); |
166 | 157 | ||
167 | return 0; | 158 | return 0; |
168 | |||
169 | out_unmap: | ||
170 | iounmap(addr); | ||
171 | platform_set_drvdata(pdev, NULL); | ||
172 | |||
173 | out_release_region: | ||
174 | release_mem_region(res->start, resource_size(res)); | ||
175 | |||
176 | return ret; | ||
177 | } | 159 | } |
178 | 160 | ||
179 | /** | 161 | /** |
@@ -186,8 +168,6 @@ static int stmmac_pltfr_remove(struct platform_device *pdev) | |||
186 | { | 168 | { |
187 | struct net_device *ndev = platform_get_drvdata(pdev); | 169 | struct net_device *ndev = platform_get_drvdata(pdev); |
188 | struct stmmac_priv *priv = netdev_priv(ndev); | 170 | struct stmmac_priv *priv = netdev_priv(ndev); |
189 | void __iomem *addr = priv->ioaddr; | ||
190 | struct resource *res; | ||
191 | int ret = stmmac_dvr_remove(ndev); | 171 | int ret = stmmac_dvr_remove(ndev); |
192 | 172 | ||
193 | if (priv->plat->exit) | 173 | if (priv->plat->exit) |
@@ -195,10 +175,6 @@ static int stmmac_pltfr_remove(struct platform_device *pdev) | |||
195 | 175 | ||
196 | platform_set_drvdata(pdev, NULL); | 176 | platform_set_drvdata(pdev, NULL); |
197 | 177 | ||
198 | iounmap(addr); | ||
199 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
200 | release_mem_region(res->start, resource_size(res)); | ||
201 | |||
202 | return ret; | 178 | return ret; |
203 | } | 179 | } |
204 | 180 | ||