Commit e4d43c17 authored by Sachin Kamat's avatar Sachin Kamat Committed by Vinod Koul

DMA: PL330: Use devm_* functions

devm_* functions are device managed and make the code and error
handling a bit simpler.

Cc: Jassi Brar <jassisinghbrar@gmail.com>
Signed-off-by: default avatarSachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: default avatarVinod Koul <vinod.koul@linux.intel.com>
parent a14acb4a
...@@ -2866,7 +2866,7 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id) ...@@ -2866,7 +2866,7 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id)
pdat = adev->dev.platform_data; pdat = adev->dev.platform_data;
/* Allocate a new DMAC and its Channels */ /* Allocate a new DMAC and its Channels */
pdmac = kzalloc(sizeof(*pdmac), GFP_KERNEL); pdmac = devm_kzalloc(&adev->dev, sizeof(*pdmac), GFP_KERNEL);
if (!pdmac) { if (!pdmac) {
dev_err(&adev->dev, "unable to allocate mem\n"); dev_err(&adev->dev, "unable to allocate mem\n");
return -ENOMEM; return -ENOMEM;
...@@ -2878,13 +2878,9 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id) ...@@ -2878,13 +2878,9 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id)
pi->mcbufsz = pdat ? pdat->mcbuf_sz : 0; pi->mcbufsz = pdat ? pdat->mcbuf_sz : 0;
res = &adev->res; res = &adev->res;
request_mem_region(res->start, resource_size(res), "dma-pl330"); pi->base = devm_request_and_ioremap(&adev->dev, res);
if (!pi->base)
pi->base = ioremap(res->start, resource_size(res)); return -ENXIO;
if (!pi->base) {
ret = -ENXIO;
goto probe_err1;
}
amba_set_drvdata(adev, pdmac); amba_set_drvdata(adev, pdmac);
...@@ -2892,11 +2888,11 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id) ...@@ -2892,11 +2888,11 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id)
ret = request_irq(irq, pl330_irq_handler, 0, ret = request_irq(irq, pl330_irq_handler, 0,
dev_name(&adev->dev), pi); dev_name(&adev->dev), pi);
if (ret) if (ret)
goto probe_err2; return ret;
ret = pl330_add(pi); ret = pl330_add(pi);
if (ret) if (ret)
goto probe_err3; goto probe_err1;
INIT_LIST_HEAD(&pdmac->desc_pool); INIT_LIST_HEAD(&pdmac->desc_pool);
spin_lock_init(&pdmac->pool_lock); spin_lock_init(&pdmac->pool_lock);
...@@ -2918,7 +2914,7 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id) ...@@ -2918,7 +2914,7 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id)
if (!pdmac->peripherals) { if (!pdmac->peripherals) {
ret = -ENOMEM; ret = -ENOMEM;
dev_err(&adev->dev, "unable to allocate pdmac->peripherals\n"); dev_err(&adev->dev, "unable to allocate pdmac->peripherals\n");
goto probe_err4; goto probe_err2;
} }
for (i = 0; i < num_chan; i++) { for (i = 0; i < num_chan; i++) {
...@@ -2962,7 +2958,7 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id) ...@@ -2962,7 +2958,7 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id)
ret = dma_async_device_register(pd); ret = dma_async_device_register(pd);
if (ret) { if (ret) {
dev_err(&adev->dev, "unable to register DMAC\n"); dev_err(&adev->dev, "unable to register DMAC\n");
goto probe_err4; goto probe_err2;
} }
dev_info(&adev->dev, dev_info(&adev->dev,
...@@ -2975,15 +2971,10 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id) ...@@ -2975,15 +2971,10 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id)
return 0; return 0;
probe_err4:
pl330_del(pi);
probe_err3:
free_irq(irq, pi);
probe_err2: probe_err2:
iounmap(pi->base); pl330_del(pi);
probe_err1: probe_err1:
release_mem_region(res->start, resource_size(res)); free_irq(irq, pi);
kfree(pdmac);
return ret; return ret;
} }
...@@ -2993,7 +2984,6 @@ static int __devexit pl330_remove(struct amba_device *adev) ...@@ -2993,7 +2984,6 @@ static int __devexit pl330_remove(struct amba_device *adev)
struct dma_pl330_dmac *pdmac = amba_get_drvdata(adev); struct dma_pl330_dmac *pdmac = amba_get_drvdata(adev);
struct dma_pl330_chan *pch, *_p; struct dma_pl330_chan *pch, *_p;
struct pl330_info *pi; struct pl330_info *pi;
struct resource *res;
int irq; int irq;
if (!pdmac) if (!pdmac)
...@@ -3020,13 +3010,6 @@ static int __devexit pl330_remove(struct amba_device *adev) ...@@ -3020,13 +3010,6 @@ static int __devexit pl330_remove(struct amba_device *adev)
irq = adev->irq[0]; irq = adev->irq[0];
free_irq(irq, pi); free_irq(irq, pi);
iounmap(pi->base);
res = &adev->res;
release_mem_region(res->start, resource_size(res));
kfree(pdmac);
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