* [PATCH] dw_dmac: use devm_* functions to simplify code
@ 2012-07-24 8:00 Andy Shevchenko
2012-07-24 8:08 ` viresh kumar
2012-07-26 6:15 ` Vinod Koul
0 siblings, 2 replies; 3+ messages in thread
From: Andy Shevchenko @ 2012-07-24 8:00 UTC (permalink / raw)
To: Vinod Koul, linux-kernel, spear-devel; +Cc: Andy Shevchenko, Viresh Kumar
Use devm_kzalloc, devm_clk_get, devm_request_irq, and devm_request_and_ioremap
to reduce the code and to simplify the error path.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Viresh Kumar <viresh.linux@gmail.com>
---
drivers/dma/dw_dmac.c | 53 +++++++++-----------------------------------
drivers/dma/dw_dmac_regs.h | 2 --
2 files changed, 10 insertions(+), 45 deletions(-)
diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c
index 3d061c6..832538c 100644
--- a/drivers/dma/dw_dmac.c
+++ b/drivers/dma/dw_dmac.c
@@ -1394,26 +1394,17 @@ static int __devinit dw_probe(struct platform_device *pdev)
size = sizeof(struct dw_dma);
size += pdata->nr_channels * sizeof(struct dw_dma_chan);
- dw = kzalloc(size, GFP_KERNEL);
+ dw = devm_kzalloc(&pdev->dev, size, GFP_KERNEL);
if (!dw)
return -ENOMEM;
- if (!request_mem_region(io->start, DW_REGLEN, pdev->dev.driver->name)) {
- err = -EBUSY;
- goto err_kfree;
- }
-
- dw->regs = ioremap(io->start, DW_REGLEN);
- if (!dw->regs) {
- err = -ENOMEM;
- goto err_release_r;
- }
+ dw->regs = devm_request_and_ioremap(&pdev->dev, io);
+ if (!dw->regs)
+ return -EBUSY;
- dw->clk = clk_get(&pdev->dev, "hclk");
- if (IS_ERR(dw->clk)) {
- err = PTR_ERR(dw->clk);
- goto err_clk;
- }
+ dw->clk = devm_clk_get(&pdev->dev, "hclk");
+ if (IS_ERR(dw->clk))
+ return PTR_ERR(dw->clk);
clk_prepare_enable(dw->clk);
/* Calculate all channel mask before DMA setup */
@@ -1425,9 +1416,10 @@ static int __devinit dw_probe(struct platform_device *pdev)
/* disable BLOCK interrupts as well */
channel_clear_bit(dw, MASK.BLOCK, dw->all_chan_mask);
- err = request_irq(irq, dw_dma_interrupt, 0, "dw_dmac", dw);
+ err = devm_request_irq(&pdev->dev, irq, dw_dma_interrupt, 0,
+ "dw_dmac", dw);
if (err)
- goto err_irq;
+ return err;
platform_set_drvdata(pdev, dw);
@@ -1493,30 +1485,16 @@ static int __devinit dw_probe(struct platform_device *pdev)
dma_async_device_register(&dw->dma);
return 0;
-
-err_irq:
- clk_disable_unprepare(dw->clk);
- clk_put(dw->clk);
-err_clk:
- iounmap(dw->regs);
- dw->regs = NULL;
-err_release_r:
- release_resource(io);
-err_kfree:
- kfree(dw);
- return err;
}
static int __devexit dw_remove(struct platform_device *pdev)
{
struct dw_dma *dw = platform_get_drvdata(pdev);
struct dw_dma_chan *dwc, *_dwc;
- struct resource *io;
dw_dma_off(dw);
dma_async_device_unregister(&dw->dma);
- free_irq(platform_get_irq(pdev, 0), dw);
tasklet_kill(&dw->tasklet);
list_for_each_entry_safe(dwc, _dwc, &dw->dma.channels,
@@ -1525,17 +1503,6 @@ static int __devexit dw_remove(struct platform_device *pdev)
channel_clear_bit(dw, CH_EN, dwc->mask);
}
- clk_disable_unprepare(dw->clk);
- clk_put(dw->clk);
-
- iounmap(dw->regs);
- dw->regs = NULL;
-
- io = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- release_mem_region(io->start, DW_REGLEN);
-
- kfree(dw);
-
return 0;
}
diff --git a/drivers/dma/dw_dmac_regs.h b/drivers/dma/dw_dmac_regs.h
index 50830be..f6d92d7 100644
--- a/drivers/dma/dw_dmac_regs.h
+++ b/drivers/dma/dw_dmac_regs.h
@@ -140,8 +140,6 @@ struct dw_dma_regs {
/* Bitfields in CFG */
#define DW_CFG_DMA_EN (1 << 0)
-#define DW_REGLEN 0x400
-
enum dw_dmac_flags {
DW_DMA_IS_CYCLIC = 0,
};
--
1.7.10.4
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] dw_dmac: use devm_* functions to simplify code
2012-07-24 8:00 [PATCH] dw_dmac: use devm_* functions to simplify code Andy Shevchenko
@ 2012-07-24 8:08 ` viresh kumar
2012-07-26 6:15 ` Vinod Koul
1 sibling, 0 replies; 3+ messages in thread
From: viresh kumar @ 2012-07-24 8:08 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: Vinod Koul, linux-kernel, spear-devel
On Tue, Jul 24, 2012 at 9:00 AM, Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
> Use devm_kzalloc, devm_clk_get, devm_request_irq, and devm_request_and_ioremap
> to reduce the code and to simplify the error path.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Cc: Viresh Kumar <viresh.linux@gmail.com>
> ---
> drivers/dma/dw_dmac.c | 53 +++++++++-----------------------------------
> drivers/dma/dw_dmac_regs.h | 2 --
> 2 files changed, 10 insertions(+), 45 deletions(-)
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] dw_dmac: use devm_* functions to simplify code
2012-07-24 8:00 [PATCH] dw_dmac: use devm_* functions to simplify code Andy Shevchenko
2012-07-24 8:08 ` viresh kumar
@ 2012-07-26 6:15 ` Vinod Koul
1 sibling, 0 replies; 3+ messages in thread
From: Vinod Koul @ 2012-07-26 6:15 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: linux-kernel, spear-devel, Viresh Kumar
On Tue, 2012-07-24 at 11:00 +0300, Andy Shevchenko wrote:
> Use devm_kzalloc, devm_clk_get, devm_request_irq, and devm_request_and_ioremap
> to reduce the code and to simplify the error path.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Cc: Viresh Kumar <viresh.linux@gmail.com>
Applied thanks
--
~Vinod
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-07-26 6:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-24 8:00 [PATCH] dw_dmac: use devm_* functions to simplify code Andy Shevchenko
2012-07-24 8:08 ` viresh kumar
2012-07-26 6:15 ` Vinod Koul
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®