[media] drivers/media/platform/soc_camera/pxa_camera.c: use devm_ functions
This patch uses various devm_ functions for data that is allocated in the probe function of a platform driver and is only freed in the remove function. This also fixes a checkpatch warning, removing a space before a \n in a string. Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
parent
ec34e1d579
commit
47de201c73
|
@ -1661,23 +1661,18 @@ static int pxa_camera_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||||
irq = platform_get_irq(pdev, 0);
|
irq = platform_get_irq(pdev, 0);
|
||||||
if (!res || irq < 0) {
|
if (!res || irq < 0)
|
||||||
err = -ENODEV;
|
return -ENODEV;
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
pcdev = kzalloc(sizeof(*pcdev), GFP_KERNEL);
|
pcdev = devm_kzalloc(&pdev->dev, sizeof(*pcdev), GFP_KERNEL);
|
||||||
if (!pcdev) {
|
if (!pcdev) {
|
||||||
dev_err(&pdev->dev, "Could not allocate pcdev\n");
|
dev_err(&pdev->dev, "Could not allocate pcdev\n");
|
||||||
err = -ENOMEM;
|
return -ENOMEM;
|
||||||
goto exit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pcdev->clk = clk_get(&pdev->dev, NULL);
|
pcdev->clk = devm_clk_get(&pdev->dev, NULL);
|
||||||
if (IS_ERR(pcdev->clk)) {
|
if (IS_ERR(pcdev->clk))
|
||||||
err = PTR_ERR(pcdev->clk);
|
return PTR_ERR(pcdev->clk);
|
||||||
goto exit_kfree;
|
|
||||||
}
|
|
||||||
|
|
||||||
pcdev->res = res;
|
pcdev->res = res;
|
||||||
|
|
||||||
|
@ -1715,17 +1710,9 @@ static int pxa_camera_probe(struct platform_device *pdev)
|
||||||
/*
|
/*
|
||||||
* Request the regions.
|
* Request the regions.
|
||||||
*/
|
*/
|
||||||
if (!request_mem_region(res->start, resource_size(res),
|
base = devm_request_and_ioremap(&pdev->dev, res);
|
||||||
PXA_CAM_DRV_NAME)) {
|
if (!base)
|
||||||
err = -EBUSY;
|
return -ENOMEM;
|
||||||
goto exit_clk;
|
|
||||||
}
|
|
||||||
|
|
||||||
base = ioremap(res->start, resource_size(res));
|
|
||||||
if (!base) {
|
|
||||||
err = -ENOMEM;
|
|
||||||
goto exit_release;
|
|
||||||
}
|
|
||||||
pcdev->irq = irq;
|
pcdev->irq = irq;
|
||||||
pcdev->base = base;
|
pcdev->base = base;
|
||||||
|
|
||||||
|
@ -1734,7 +1721,7 @@ static int pxa_camera_probe(struct platform_device *pdev)
|
||||||
pxa_camera_dma_irq_y, pcdev);
|
pxa_camera_dma_irq_y, pcdev);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
dev_err(&pdev->dev, "Can't request DMA for Y\n");
|
dev_err(&pdev->dev, "Can't request DMA for Y\n");
|
||||||
goto exit_iounmap;
|
return err;
|
||||||
}
|
}
|
||||||
pcdev->dma_chans[0] = err;
|
pcdev->dma_chans[0] = err;
|
||||||
dev_dbg(&pdev->dev, "got DMA channel %d\n", pcdev->dma_chans[0]);
|
dev_dbg(&pdev->dev, "got DMA channel %d\n", pcdev->dma_chans[0]);
|
||||||
|
@ -1762,8 +1749,8 @@ static int pxa_camera_probe(struct platform_device *pdev)
|
||||||
DRCMR(70) = pcdev->dma_chans[2] | DRCMR_MAPVLD;
|
DRCMR(70) = pcdev->dma_chans[2] | DRCMR_MAPVLD;
|
||||||
|
|
||||||
/* request irq */
|
/* request irq */
|
||||||
err = request_irq(pcdev->irq, pxa_camera_irq, 0, PXA_CAM_DRV_NAME,
|
err = devm_request_irq(&pdev->dev, pcdev->irq, pxa_camera_irq, 0,
|
||||||
pcdev);
|
PXA_CAM_DRV_NAME, pcdev);
|
||||||
if (err) {
|
if (err) {
|
||||||
dev_err(&pdev->dev, "Camera interrupt register failed\n");
|
dev_err(&pdev->dev, "Camera interrupt register failed\n");
|
||||||
goto exit_free_dma;
|
goto exit_free_dma;
|
||||||
|
@ -1777,27 +1764,16 @@ static int pxa_camera_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
err = soc_camera_host_register(&pcdev->soc_host);
|
err = soc_camera_host_register(&pcdev->soc_host);
|
||||||
if (err)
|
if (err)
|
||||||
goto exit_free_irq;
|
goto exit_free_dma;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
exit_free_irq:
|
|
||||||
free_irq(pcdev->irq, pcdev);
|
|
||||||
exit_free_dma:
|
exit_free_dma:
|
||||||
pxa_free_dma(pcdev->dma_chans[2]);
|
pxa_free_dma(pcdev->dma_chans[2]);
|
||||||
exit_free_dma_u:
|
exit_free_dma_u:
|
||||||
pxa_free_dma(pcdev->dma_chans[1]);
|
pxa_free_dma(pcdev->dma_chans[1]);
|
||||||
exit_free_dma_y:
|
exit_free_dma_y:
|
||||||
pxa_free_dma(pcdev->dma_chans[0]);
|
pxa_free_dma(pcdev->dma_chans[0]);
|
||||||
exit_iounmap:
|
|
||||||
iounmap(base);
|
|
||||||
exit_release:
|
|
||||||
release_mem_region(res->start, resource_size(res));
|
|
||||||
exit_clk:
|
|
||||||
clk_put(pcdev->clk);
|
|
||||||
exit_kfree:
|
|
||||||
kfree(pcdev);
|
|
||||||
exit:
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1806,24 +1782,13 @@ static int pxa_camera_remove(struct platform_device *pdev)
|
||||||
struct soc_camera_host *soc_host = to_soc_camera_host(&pdev->dev);
|
struct soc_camera_host *soc_host = to_soc_camera_host(&pdev->dev);
|
||||||
struct pxa_camera_dev *pcdev = container_of(soc_host,
|
struct pxa_camera_dev *pcdev = container_of(soc_host,
|
||||||
struct pxa_camera_dev, soc_host);
|
struct pxa_camera_dev, soc_host);
|
||||||
struct resource *res;
|
|
||||||
|
|
||||||
clk_put(pcdev->clk);
|
|
||||||
|
|
||||||
pxa_free_dma(pcdev->dma_chans[0]);
|
pxa_free_dma(pcdev->dma_chans[0]);
|
||||||
pxa_free_dma(pcdev->dma_chans[1]);
|
pxa_free_dma(pcdev->dma_chans[1]);
|
||||||
pxa_free_dma(pcdev->dma_chans[2]);
|
pxa_free_dma(pcdev->dma_chans[2]);
|
||||||
free_irq(pcdev->irq, pcdev);
|
|
||||||
|
|
||||||
soc_camera_host_unregister(soc_host);
|
soc_camera_host_unregister(soc_host);
|
||||||
|
|
||||||
iounmap(pcdev->base);
|
|
||||||
|
|
||||||
res = pcdev->res;
|
|
||||||
release_mem_region(res->start, resource_size(res));
|
|
||||||
|
|
||||||
kfree(pcdev);
|
|
||||||
|
|
||||||
dev_info(&pdev->dev, "PXA Camera driver unloaded\n");
|
dev_info(&pdev->dev, "PXA Camera driver unloaded\n");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue