Skip to content

Commit 8bfe4a6

Browse files
ambarusvinodkoul
authored andcommitted
dmaengine: at_hdmac: Use devm_platform_ioremap_resource
Use devm_platform_ioremap_resource() helper for cleanner code and easier resource management. Signed-off-by: Tudor Ambarus <[email protected]> Acked-by: Nicolas Ferre <[email protected]> Link: https://lore.kernel.org/r/[email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 5f1d429 commit 8bfe4a6

File tree

1 file changed

+6
-31
lines changed

1 file changed

+6
-31
lines changed

drivers/dma/at_hdmac.c

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1765,9 +1765,7 @@ static void at_dma_off(struct at_dma *atdma)
17651765

17661766
static int __init at_dma_probe(struct platform_device *pdev)
17671767
{
1768-
struct resource *io;
17691768
struct at_dma *atdma;
1770-
size_t size;
17711769
int irq;
17721770
int err;
17731771
int i;
@@ -1793,9 +1791,9 @@ static int __init at_dma_probe(struct platform_device *pdev)
17931791
if (!atdma)
17941792
return -ENOMEM;
17951793

1796-
io = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1797-
if (!io)
1798-
return -EINVAL;
1794+
atdma->regs = devm_platform_ioremap_resource(pdev, 0);
1795+
if (IS_ERR(atdma->regs))
1796+
return PTR_ERR(atdma->regs);
17991797

18001798
irq = platform_get_irq(pdev, 0);
18011799
if (irq < 0)
@@ -1805,21 +1803,10 @@ static int __init at_dma_probe(struct platform_device *pdev)
18051803
atdma->dma_common.cap_mask = plat_dat->cap_mask;
18061804
atdma->all_chan_mask = (1 << plat_dat->nr_channels) - 1;
18071805

1808-
size = resource_size(io);
1809-
if (!request_mem_region(io->start, size, pdev->dev.driver->name))
1810-
return -EBUSY;
1811-
1812-
atdma->regs = ioremap(io->start, size);
1813-
if (!atdma->regs) {
1814-
err = -ENOMEM;
1815-
goto err_release_r;
1816-
}
1817-
18181806
atdma->clk = clk_get(&pdev->dev, "dma_clk");
1819-
if (IS_ERR(atdma->clk)) {
1820-
err = PTR_ERR(atdma->clk);
1821-
goto err_clk;
1822-
}
1807+
if (IS_ERR(atdma->clk))
1808+
return PTR_ERR(atdma->clk);
1809+
18231810
err = clk_prepare_enable(atdma->clk);
18241811
if (err)
18251812
goto err_clk_prepare;
@@ -1957,19 +1944,13 @@ static int __init at_dma_probe(struct platform_device *pdev)
19571944
clk_disable_unprepare(atdma->clk);
19581945
err_clk_prepare:
19591946
clk_put(atdma->clk);
1960-
err_clk:
1961-
iounmap(atdma->regs);
1962-
atdma->regs = NULL;
1963-
err_release_r:
1964-
release_mem_region(io->start, size);
19651947
return err;
19661948
}
19671949

19681950
static int at_dma_remove(struct platform_device *pdev)
19691951
{
19701952
struct at_dma *atdma = platform_get_drvdata(pdev);
19711953
struct dma_chan *chan, *_chan;
1972-
struct resource *io;
19731954

19741955
at_dma_off(atdma);
19751956
if (pdev->dev.of_node)
@@ -1994,12 +1975,6 @@ static int at_dma_remove(struct platform_device *pdev)
19941975
clk_disable_unprepare(atdma->clk);
19951976
clk_put(atdma->clk);
19961977

1997-
iounmap(atdma->regs);
1998-
atdma->regs = NULL;
1999-
2000-
io = platform_get_resource(pdev, IORESOURCE_MEM, 0);
2001-
release_mem_region(io->start, resource_size(io));
2002-
20031978
return 0;
20041979
}
20051980

0 commit comments

Comments
 (0)