Commit 0bc8a718 authored by Sachin Kamat's avatar Sachin Kamat Committed by Herbert Xu

crypto: dcp - Use devm_* APIs

devm_* APIs are device managed and make cleanup and exit
code simpler.
Signed-off-by: default avatarSachin Kamat <sachin.kamat@linaro.org>
Tested-by: default avatarTobias Rauter <tobiasrauter@gmail.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent d6dfd683
...@@ -723,12 +723,10 @@ static int dcp_probe(struct platform_device *pdev) ...@@ -723,12 +723,10 @@ static int dcp_probe(struct platform_device *pdev)
struct resource *r; struct resource *r;
int i, ret, j; int i, ret, j;
dev = kzalloc(sizeof(*dev), GFP_KERNEL); dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
if (dev == NULL) { if (!dev)
dev_err(&pdev->dev, "Failed to allocate structure\n"); return -ENOMEM;
ret = -ENOMEM;
goto err;
}
global_dev = dev; global_dev = dev;
dev->dev = &pdev->dev; dev->dev = &pdev->dev;
...@@ -737,11 +735,10 @@ static int dcp_probe(struct platform_device *pdev) ...@@ -737,11 +735,10 @@ static int dcp_probe(struct platform_device *pdev)
r = platform_get_resource(pdev, IORESOURCE_MEM, 0); r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!r) { if (!r) {
dev_err(&pdev->dev, "failed to get IORESOURCE_MEM\n"); dev_err(&pdev->dev, "failed to get IORESOURCE_MEM\n");
ret = -ENXIO; return -ENXIO;
goto err_dev;
} }
dev->dcp_regs_base = ioremap(r->start, resource_size(r)); dev->dcp_regs_base = devm_ioremap(&pdev->dev, r->start,
resource_size(r));
dcp_set(dev, DCP_CTRL_SFRST, DCP_REG_CTRL); dcp_set(dev, DCP_CTRL_SFRST, DCP_REG_CTRL);
udelay(10); udelay(10);
...@@ -762,15 +759,13 @@ static int dcp_probe(struct platform_device *pdev) ...@@ -762,15 +759,13 @@ static int dcp_probe(struct platform_device *pdev)
r = platform_get_resource(pdev, IORESOURCE_IRQ, 0); r = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
if (!r) { if (!r) {
dev_err(&pdev->dev, "can't get IRQ resource (0)\n"); dev_err(&pdev->dev, "can't get IRQ resource (0)\n");
ret = -EIO; return -EIO;
goto err_unmap_mem;
} }
dev->dcp_vmi_irq = r->start; dev->dcp_vmi_irq = r->start;
ret = request_irq(dev->dcp_vmi_irq, dcp_vmi_irq, 0, "dcp", dev); ret = request_irq(dev->dcp_vmi_irq, dcp_vmi_irq, 0, "dcp", dev);
if (ret != 0) { if (ret != 0) {
dev_err(&pdev->dev, "can't request_irq (0)\n"); dev_err(&pdev->dev, "can't request_irq (0)\n");
ret = -EIO; return -EIO;
goto err_unmap_mem;
} }
r = platform_get_resource(pdev, IORESOURCE_IRQ, 1); r = platform_get_resource(pdev, IORESOURCE_IRQ, 1);
...@@ -863,11 +858,7 @@ static int dcp_probe(struct platform_device *pdev) ...@@ -863,11 +858,7 @@ static int dcp_probe(struct platform_device *pdev)
free_irq(dev->dcp_irq, dev); free_irq(dev->dcp_irq, dev);
err_free_irq0: err_free_irq0:
free_irq(dev->dcp_vmi_irq, dev); free_irq(dev->dcp_vmi_irq, dev);
err_unmap_mem:
iounmap((void *) dev->dcp_regs_base);
err_dev:
kfree(dev);
err:
return ret; return ret;
} }
...@@ -890,14 +881,11 @@ static int dcp_remove(struct platform_device *pdev) ...@@ -890,14 +881,11 @@ static int dcp_remove(struct platform_device *pdev)
tasklet_kill(&dev->done_task); tasklet_kill(&dev->done_task);
tasklet_kill(&dev->queue_task); tasklet_kill(&dev->queue_task);
iounmap((void *) dev->dcp_regs_base);
for (j = 0; j < ARRAY_SIZE(algs); j++) for (j = 0; j < ARRAY_SIZE(algs); j++)
crypto_unregister_alg(&algs[j]); crypto_unregister_alg(&algs[j]);
misc_deregister(&dev->dcp_bootstream_misc); misc_deregister(&dev->dcp_bootstream_misc);
kfree(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