linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] DMA: PL330: Use devm_* functions
@ 2012-11-15  6:27 Sachin Kamat
       [not found] ` <CAK9yfHzLL9K=M6nyafiEgXmtqFGWq2vA=6nO5JMeAzo-M1HcwA@mail.gmail.com>
  2012-12-04  8:19 ` Andy Shevchenko
  0 siblings, 2 replies; 3+ messages in thread
From: Sachin Kamat @ 2012-11-15  6:27 UTC (permalink / raw)
  To: linux-kernel; +Cc: vinod.koul, sachin.kamat, patches, Jassi Brar

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

Cc: Jassi Brar <jassisinghbrar@gmail.com>
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
 drivers/dma/pl330.c |   37 ++++++++++---------------------------
 1 files changed, 10 insertions(+), 27 deletions(-)

diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c
index 665668b..68aa24c 100644
--- a/drivers/dma/pl330.c
+++ b/drivers/dma/pl330.c
@@ -2866,7 +2866,7 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id)
 	pdat = adev->dev.platform_data;
 
 	/* Allocate a new DMAC and its Channels */
-	pdmac = kzalloc(sizeof(*pdmac), GFP_KERNEL);
+	pdmac = devm_kzalloc(&adev->dev, sizeof(*pdmac), GFP_KERNEL);
 	if (!pdmac) {
 		dev_err(&adev->dev, "unable to allocate mem\n");
 		return -ENOMEM;
@@ -2878,13 +2878,9 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id)
 	pi->mcbufsz = pdat ? pdat->mcbuf_sz : 0;
 
 	res = &adev->res;
-	request_mem_region(res->start, resource_size(res), "dma-pl330");
-
-	pi->base = ioremap(res->start, resource_size(res));
-	if (!pi->base) {
-		ret = -ENXIO;
-		goto probe_err1;
-	}
+	pi->base = devm_request_and_ioremap(&adev->dev, res);
+	if (!pi->base)
+		return -ENXIO;
 
 	amba_set_drvdata(adev, pdmac);
 
@@ -2892,11 +2888,11 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id)
 	ret = request_irq(irq, pl330_irq_handler, 0,
 			dev_name(&adev->dev), pi);
 	if (ret)
-		goto probe_err2;
+		return ret;
 
 	ret = pl330_add(pi);
 	if (ret)
-		goto probe_err3;
+		goto probe_err1;
 
 	INIT_LIST_HEAD(&pdmac->desc_pool);
 	spin_lock_init(&pdmac->pool_lock);
@@ -2918,7 +2914,7 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id)
 	if (!pdmac->peripherals) {
 		ret = -ENOMEM;
 		dev_err(&adev->dev, "unable to allocate pdmac->peripherals\n");
-		goto probe_err4;
+		goto probe_err2;
 	}
 
 	for (i = 0; i < num_chan; i++) {
@@ -2962,7 +2958,7 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id)
 	ret = dma_async_device_register(pd);
 	if (ret) {
 		dev_err(&adev->dev, "unable to register DMAC\n");
-		goto probe_err4;
+		goto probe_err2;
 	}
 
 	dev_info(&adev->dev,
@@ -2975,15 +2971,10 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id)
 
 	return 0;
 
-probe_err4:
-	pl330_del(pi);
-probe_err3:
-	free_irq(irq, pi);
 probe_err2:
-	iounmap(pi->base);
+	pl330_del(pi);
 probe_err1:
-	release_mem_region(res->start, resource_size(res));
-	kfree(pdmac);
+	free_irq(irq, pi);
 
 	return ret;
 }
@@ -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_chan *pch, *_p;
 	struct pl330_info *pi;
-	struct resource *res;
 	int irq;
 
 	if (!pdmac)
@@ -3020,13 +3010,6 @@ static int __devexit pl330_remove(struct amba_device *adev)
 	irq = adev->irq[0];
 	free_irq(irq, pi);
 
-	iounmap(pi->base);
-
-	res = &adev->res;
-	release_mem_region(res->start, resource_size(res));
-
-	kfree(pdmac);
-
 	return 0;
 }
 
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] DMA: PL330: Use devm_* functions
       [not found] ` <CAK9yfHzLL9K=M6nyafiEgXmtqFGWq2vA=6nO5JMeAzo-M1HcwA@mail.gmail.com>
@ 2012-12-03 17:17   ` Vinod Koul
  0 siblings, 0 replies; 3+ messages in thread
From: Vinod Koul @ 2012-12-03 17:17 UTC (permalink / raw)
  To: Sachin Kamat; +Cc: vinod.koul, Jassi Brar, linux-kernel, patches

On Mon, 2012-12-03 at 16:50 +0530, Sachin Kamat wrote:
> On 15 November 2012 11:57, Sachin Kamat <sachin.kamat@linaro.org> wrote:
> > devm_* functions are device managed and make the code and error
> > handling a bit simpler.
> >
> > Cc: Jassi Brar <jassisinghbrar@gmail.com>
> > Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Applied, Thanks


-- 
Vinod Koul
Intel Corp.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] DMA: PL330: Use devm_* functions
  2012-11-15  6:27 [PATCH 1/1] DMA: PL330: Use devm_* functions Sachin Kamat
       [not found] ` <CAK9yfHzLL9K=M6nyafiEgXmtqFGWq2vA=6nO5JMeAzo-M1HcwA@mail.gmail.com>
@ 2012-12-04  8:19 ` Andy Shevchenko
  1 sibling, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2012-12-04  8:19 UTC (permalink / raw)
  To: Sachin Kamat; +Cc: linux-kernel, vinod.koul, patches, Jassi Brar

On Thu, Nov 15, 2012 at 8:27 AM, Sachin Kamat <sachin.kamat@linaro.org> wrote:
> devm_* functions are device managed and make the code and error
> handling a bit simpler.

You may add devm_request_irq to the bunch as well.

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-12-04  8:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-15  6:27 [PATCH 1/1] DMA: PL330: Use devm_* functions Sachin Kamat
     [not found] ` <CAK9yfHzLL9K=M6nyafiEgXmtqFGWq2vA=6nO5JMeAzo-M1HcwA@mail.gmail.com>
2012-12-03 17:17   ` Vinod Koul
2012-12-04  8:19 ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).