Commit 342180f7 authored by Florian Vaussard's avatar Florian Vaussard Committed by Marc Kleine-Budde

can: sja1000: platform: use devm_* APIs

Simplify probe and remove functions by converting most of the resources
to use devm_* APIs.
Signed-off-by: default avatarFlorian Vaussard <florian.vaussard@epfl.ch>
Tested-by: default avatarAndreas Larsson <andreas@gaisler.com>
Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
parent 909285c4
...@@ -78,34 +78,26 @@ static int sp_probe(struct platform_device *pdev) ...@@ -78,34 +78,26 @@ static int sp_probe(struct platform_device *pdev)
pdata = dev_get_platdata(&pdev->dev); pdata = dev_get_platdata(&pdev->dev);
if (!pdata) { if (!pdata) {
dev_err(&pdev->dev, "No platform data provided!\n"); dev_err(&pdev->dev, "No platform data provided!\n");
err = -ENODEV; return -ENODEV;
goto exit;
} }
res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
res_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); res_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
if (!res_mem || !res_irq) { if (!res_mem || !res_irq)
err = -ENODEV; return -ENODEV;
goto exit;
}
if (!request_mem_region(res_mem->start, resource_size(res_mem), if (!devm_request_mem_region(&pdev->dev, res_mem->start,
DRV_NAME)) { resource_size(res_mem), DRV_NAME))
err = -EBUSY; return -EBUSY;
goto exit;
}
addr = ioremap_nocache(res_mem->start, resource_size(res_mem)); addr = devm_ioremap_nocache(&pdev->dev, res_mem->start,
if (!addr) { resource_size(res_mem));
err = -ENOMEM; if (!addr)
goto exit_release; return -ENOMEM;
}
dev = alloc_sja1000dev(0); dev = alloc_sja1000dev(0);
if (!dev) { if (!dev)
err = -ENOMEM; return -ENOMEM;
goto exit_iounmap;
}
priv = netdev_priv(dev); priv = netdev_priv(dev);
dev->irq = res_irq->start; dev->irq = res_irq->start;
...@@ -150,28 +142,14 @@ static int sp_probe(struct platform_device *pdev) ...@@ -150,28 +142,14 @@ static int sp_probe(struct platform_device *pdev)
exit_free: exit_free:
free_sja1000dev(dev); free_sja1000dev(dev);
exit_iounmap:
iounmap(addr);
exit_release:
release_mem_region(res_mem->start, resource_size(res_mem));
exit:
return err; return err;
} }
static int sp_remove(struct platform_device *pdev) static int sp_remove(struct platform_device *pdev)
{ {
struct net_device *dev = platform_get_drvdata(pdev); struct net_device *dev = platform_get_drvdata(pdev);
struct sja1000_priv *priv = netdev_priv(dev);
struct resource *res;
unregister_sja1000dev(dev); unregister_sja1000dev(dev);
if (priv->reg_base)
iounmap(priv->reg_base);
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
release_mem_region(res->start, resource_size(res));
free_sja1000dev(dev); free_sja1000dev(dev);
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment