aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/can
diff options
context:
space:
mode:
authorLad, Prabhakar <prabhakar.csengg@gmail.com>2014-06-20 07:59:34 -0400
committerMarc Kleine-Budde <mkl@pengutronix.de>2014-07-15 03:32:06 -0400
commitc6bf7e5f4a2588bdee97b28b76f9c3605b11ec03 (patch)
treeb8ecbcd07ed51e271a607aac5c1da5b584a6578b /drivers/net/can
parent0854a7f13206d7523abe773235bbe4d13958fc4b (diff)
can: c_can: convert to use devm * api
This patch uses devm_* APIs as they are device managed and make code simpler. Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Diffstat (limited to 'drivers/net/can')
-rw-r--r--drivers/net/can/c_can/c_can_platform.c43
1 files changed, 10 insertions, 33 deletions
diff --git a/drivers/net/can/c_can/c_can_platform.c b/drivers/net/can/c_can/c_can_platform.c
index 824108cd9fd5..e29b6d051103 100644
--- a/drivers/net/can/c_can/c_can_platform.c
+++ b/drivers/net/can/c_can/c_can_platform.c
@@ -208,40 +208,31 @@ static int c_can_plat_probe(struct platform_device *pdev)
208 } 208 }
209 209
210 /* get the appropriate clk */ 210 /* get the appropriate clk */
211 clk = clk_get(&pdev->dev, NULL); 211 clk = devm_clk_get(&pdev->dev, NULL);
212 if (IS_ERR(clk)) { 212 if (IS_ERR(clk)) {
213 dev_err(&pdev->dev, "no clock defined\n"); 213 ret = PTR_ERR(clk);
214 ret = -ENODEV;
215 goto exit; 214 goto exit;
216 } 215 }
217 216
218 /* get the platform data */ 217 /* get the platform data */
219 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
220 irq = platform_get_irq(pdev, 0); 218 irq = platform_get_irq(pdev, 0);
221 if (!mem || irq <= 0) { 219 if (irq <= 0) {
222 ret = -ENODEV; 220 ret = -ENODEV;
223 goto exit_free_clk; 221 goto exit;
224 }
225
226 if (!request_mem_region(mem->start, resource_size(mem),
227 KBUILD_MODNAME)) {
228 dev_err(&pdev->dev, "resource unavailable\n");
229 ret = -ENODEV;
230 goto exit_free_clk;
231 } 222 }
232 223
233 addr = ioremap(mem->start, resource_size(mem)); 224 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
234 if (!addr) { 225 addr = devm_ioremap_resource(&pdev->dev, mem);
235 dev_err(&pdev->dev, "failed to map can port\n"); 226 if (IS_ERR(addr)) {
236 ret = -ENOMEM; 227 ret = PTR_ERR(addr);
237 goto exit_release_mem; 228 goto exit;
238 } 229 }
239 230
240 /* allocate the c_can device */ 231 /* allocate the c_can device */
241 dev = alloc_c_can_dev(); 232 dev = alloc_c_can_dev();
242 if (!dev) { 233 if (!dev) {
243 ret = -ENOMEM; 234 ret = -ENOMEM;
244 goto exit_iounmap; 235 goto exit;
245 } 236 }
246 237
247 priv = netdev_priv(dev); 238 priv = netdev_priv(dev);
@@ -321,12 +312,6 @@ static int c_can_plat_probe(struct platform_device *pdev)
321 312
322exit_free_device: 313exit_free_device:
323 free_c_can_dev(dev); 314 free_c_can_dev(dev);
324exit_iounmap:
325 iounmap(addr);
326exit_release_mem:
327 release_mem_region(mem->start, resource_size(mem));
328exit_free_clk:
329 clk_put(clk);
330exit: 315exit:
331 dev_err(&pdev->dev, "probe failed\n"); 316 dev_err(&pdev->dev, "probe failed\n");
332 317
@@ -336,18 +321,10 @@ exit:
336static int c_can_plat_remove(struct platform_device *pdev) 321static int c_can_plat_remove(struct platform_device *pdev)
337{ 322{
338 struct net_device *dev = platform_get_drvdata(pdev); 323 struct net_device *dev = platform_get_drvdata(pdev);
339 struct c_can_priv *priv = netdev_priv(dev);
340 struct resource *mem;
341 324
342 unregister_c_can_dev(dev); 325 unregister_c_can_dev(dev);
343 326
344 free_c_can_dev(dev); 327 free_c_can_dev(dev);
345 iounmap(priv->base);
346
347 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
348 release_mem_region(mem->start, resource_size(mem));
349
350 clk_put(priv->priv);
351 328
352 return 0; 329 return 0;
353} 330}