Commit 7f24e0ee authored by Fabio Estevam's avatar Fabio Estevam Committed by Vinod Koul

dmaengine: imx-sdma: Use devm functions

By using devm functions we can make the code shorter and cleaner.
Signed-off-by: default avatarFabio Estevam <fabio.estevam@freescale.com>
Signed-off-by: default avatarVinod Koul <vinod.koul@intel.com>
parent 1e4a4f50
...@@ -1472,7 +1472,7 @@ static int sdma_probe(struct platform_device *pdev) ...@@ -1472,7 +1472,7 @@ static int sdma_probe(struct platform_device *pdev)
if (ret) if (ret)
return ret; return ret;
sdma = kzalloc(sizeof(*sdma), GFP_KERNEL); sdma = devm_kzalloc(&pdev->dev, sizeof(*sdma), GFP_KERNEL);
if (!sdma) if (!sdma)
return -ENOMEM; return -ENOMEM;
...@@ -1481,48 +1481,34 @@ static int sdma_probe(struct platform_device *pdev) ...@@ -1481,48 +1481,34 @@ static int sdma_probe(struct platform_device *pdev)
sdma->dev = &pdev->dev; sdma->dev = &pdev->dev;
sdma->drvdata = drvdata; sdma->drvdata = drvdata;
iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
irq = platform_get_irq(pdev, 0); irq = platform_get_irq(pdev, 0);
if (!iores || irq < 0) { if (irq < 0)
ret = -EINVAL; return -EINVAL;
goto err_irq;
}
if (!request_mem_region(iores->start, resource_size(iores), pdev->name)) { iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
ret = -EBUSY; sdma->regs = devm_ioremap_resource(&pdev->dev, iores);
goto err_request_region; if (IS_ERR(sdma->regs))
} return PTR_ERR(sdma->regs);
sdma->clk_ipg = devm_clk_get(&pdev->dev, "ipg"); sdma->clk_ipg = devm_clk_get(&pdev->dev, "ipg");
if (IS_ERR(sdma->clk_ipg)) { if (IS_ERR(sdma->clk_ipg))
ret = PTR_ERR(sdma->clk_ipg); return PTR_ERR(sdma->clk_ipg);
goto err_clk;
}
sdma->clk_ahb = devm_clk_get(&pdev->dev, "ahb"); sdma->clk_ahb = devm_clk_get(&pdev->dev, "ahb");
if (IS_ERR(sdma->clk_ahb)) { if (IS_ERR(sdma->clk_ahb))
ret = PTR_ERR(sdma->clk_ahb); return PTR_ERR(sdma->clk_ahb);
goto err_clk;
}
clk_prepare(sdma->clk_ipg); clk_prepare(sdma->clk_ipg);
clk_prepare(sdma->clk_ahb); clk_prepare(sdma->clk_ahb);
sdma->regs = ioremap(iores->start, resource_size(iores)); ret = devm_request_irq(&pdev->dev, irq, sdma_int_handler, 0, "sdma",
if (!sdma->regs) { sdma);
ret = -ENOMEM;
goto err_ioremap;
}
ret = request_irq(irq, sdma_int_handler, 0, "sdma", sdma);
if (ret) if (ret)
goto err_request_irq; return ret;
sdma->script_addrs = kzalloc(sizeof(*sdma->script_addrs), GFP_KERNEL); sdma->script_addrs = kzalloc(sizeof(*sdma->script_addrs), GFP_KERNEL);
if (!sdma->script_addrs) { if (!sdma->script_addrs)
ret = -ENOMEM; return -ENOMEM;
goto err_alloc;
}
/* initially no scripts available */ /* initially no scripts available */
saddr_arr = (s32 *)sdma->script_addrs; saddr_arr = (s32 *)sdma->script_addrs;
...@@ -1627,38 +1613,22 @@ static int sdma_probe(struct platform_device *pdev) ...@@ -1627,38 +1613,22 @@ static int sdma_probe(struct platform_device *pdev)
dma_async_device_unregister(&sdma->dma_device); dma_async_device_unregister(&sdma->dma_device);
err_init: err_init:
kfree(sdma->script_addrs); kfree(sdma->script_addrs);
err_alloc:
free_irq(irq, sdma);
err_request_irq:
iounmap(sdma->regs);
err_ioremap:
err_clk:
release_mem_region(iores->start, resource_size(iores));
err_request_region:
err_irq:
kfree(sdma);
return ret; return ret;
} }
static int sdma_remove(struct platform_device *pdev) static int sdma_remove(struct platform_device *pdev)
{ {
struct sdma_engine *sdma = platform_get_drvdata(pdev); struct sdma_engine *sdma = platform_get_drvdata(pdev);
struct resource *iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
int irq = platform_get_irq(pdev, 0);
int i; int i;
dma_async_device_unregister(&sdma->dma_device); dma_async_device_unregister(&sdma->dma_device);
kfree(sdma->script_addrs); kfree(sdma->script_addrs);
free_irq(irq, sdma);
iounmap(sdma->regs);
release_mem_region(iores->start, resource_size(iores));
/* Kill the tasklet */ /* Kill the tasklet */
for (i = 0; i < MAX_DMA_CHANNELS; i++) { for (i = 0; i < MAX_DMA_CHANNELS; i++) {
struct sdma_channel *sdmac = &sdma->channel[i]; struct sdma_channel *sdmac = &sdma->channel[i];
tasklet_kill(&sdmac->tasklet); tasklet_kill(&sdmac->tasklet);
} }
kfree(sdma);
platform_set_drvdata(pdev, NULL); platform_set_drvdata(pdev, NULL);
dev_info(&pdev->dev, "Removed...\n"); dev_info(&pdev->dev, "Removed...\n");
......
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