Commit 6e1e132e authored by Sakari Ailus's avatar Sakari Ailus Committed by Mauro Carvalho Chehab

media: pxa_camera: Fix probe error handling

Fix and simplify error handling in pxa_camera probe, by moving devm_*()
functions early in the probe function and then tearing down what was set
up on error patch.
Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Tested-by: Philipp Zabel <p.zabel@pengutronix.de> # imx6qp
Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> # rcar + adv746x
Tested-by: Aishwarya Kothari <aishwarya.kothari@toradex.com> # Apalis i.MX6Q with TC358743
Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> # Renesas RZ/G2L SMARC
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
parent 1e345458
...@@ -2274,13 +2274,6 @@ static int pxa_camera_probe(struct platform_device *pdev) ...@@ -2274,13 +2274,6 @@ static int pxa_camera_probe(struct platform_device *pdev)
int irq; int irq;
int err = 0, i; int err = 0, i;
/*
* Request the regions.
*/
base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
if (IS_ERR(base))
return PTR_ERR(base);
irq = platform_get_irq(pdev, 0); irq = platform_get_irq(pdev, 0);
if (irq < 0) if (irq < 0)
return -ENODEV; return -ENODEV;
...@@ -2295,6 +2288,16 @@ static int pxa_camera_probe(struct platform_device *pdev) ...@@ -2295,6 +2288,16 @@ static int pxa_camera_probe(struct platform_device *pdev)
if (IS_ERR(pcdev->clk)) if (IS_ERR(pcdev->clk))
return PTR_ERR(pcdev->clk); return PTR_ERR(pcdev->clk);
/*
* Request the regions.
*/
base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
if (IS_ERR(base))
return PTR_ERR(base);
pcdev->irq = irq;
pcdev->base = base;
v4l2_async_nf_init(&pcdev->notifier); v4l2_async_nf_init(&pcdev->notifier);
pcdev->res = res; pcdev->res = res;
pcdev->pdata = pdev->dev.platform_data; pcdev->pdata = pdev->dev.platform_data;
...@@ -2344,14 +2347,12 @@ static int pxa_camera_probe(struct platform_device *pdev) ...@@ -2344,14 +2347,12 @@ static int pxa_camera_probe(struct platform_device *pdev)
spin_lock_init(&pcdev->lock); spin_lock_init(&pcdev->lock);
mutex_init(&pcdev->mlock); mutex_init(&pcdev->mlock);
pcdev->irq = irq;
pcdev->base = base;
/* request dma */ /* request dma */
pcdev->dma_chans[0] = dma_request_chan(&pdev->dev, "CI_Y"); pcdev->dma_chans[0] = dma_request_chan(&pdev->dev, "CI_Y");
if (IS_ERR(pcdev->dma_chans[0])) { if (IS_ERR(pcdev->dma_chans[0])) {
dev_err(&pdev->dev, "Can't request DMA for Y\n"); dev_err(&pdev->dev, "Can't request DMA for Y\n");
return PTR_ERR(pcdev->dma_chans[0]); err = PTR_ERR(pcdev->dma_chans[0]);
goto exit_notifier_cleanup;
} }
pcdev->dma_chans[1] = dma_request_chan(&pdev->dev, "CI_U"); pcdev->dma_chans[1] = dma_request_chan(&pdev->dev, "CI_U");
...@@ -2378,14 +2379,6 @@ static int pxa_camera_probe(struct platform_device *pdev) ...@@ -2378,14 +2379,6 @@ static int pxa_camera_probe(struct platform_device *pdev)
} }
} }
/* request irq */
err = devm_request_irq(&pdev->dev, pcdev->irq, pxa_camera_irq, 0,
PXA_CAM_DRV_NAME, pcdev);
if (err) {
dev_err(&pdev->dev, "Camera interrupt register failed\n");
goto exit_free_dma;
}
tasklet_setup(&pcdev->task_eof, pxa_camera_eof); tasklet_setup(&pcdev->task_eof, pxa_camera_eof);
pxa_camera_activate(pcdev); pxa_camera_activate(pcdev);
...@@ -2397,16 +2390,23 @@ static int pxa_camera_probe(struct platform_device *pdev) ...@@ -2397,16 +2390,23 @@ static int pxa_camera_probe(struct platform_device *pdev)
err = pxa_camera_init_videobuf2(pcdev); err = pxa_camera_init_videobuf2(pcdev);
if (err) if (err)
goto exit_notifier_cleanup; goto exit_v4l2_device_unregister;
/* request irq */
err = devm_request_irq(&pdev->dev, pcdev->irq, pxa_camera_irq, 0,
PXA_CAM_DRV_NAME, pcdev);
if (err) {
dev_err(&pdev->dev, "Camera interrupt register failed\n");
goto exit_v4l2_device_unregister;
}
pcdev->notifier.ops = &pxa_camera_sensor_ops; pcdev->notifier.ops = &pxa_camera_sensor_ops;
err = v4l2_async_nf_register(&pcdev->v4l2_dev, &pcdev->notifier); err = v4l2_async_nf_register(&pcdev->v4l2_dev, &pcdev->notifier);
if (err) if (err)
goto exit_notifier_cleanup; goto exit_v4l2_device_unregister;
return 0; return 0;
exit_notifier_cleanup: exit_v4l2_device_unregister:
v4l2_async_nf_cleanup(&pcdev->notifier);
v4l2_device_unregister(&pcdev->v4l2_dev); v4l2_device_unregister(&pcdev->v4l2_dev);
exit_deactivate: exit_deactivate:
pxa_camera_deactivate(pcdev); pxa_camera_deactivate(pcdev);
...@@ -2417,6 +2417,8 @@ static int pxa_camera_probe(struct platform_device *pdev) ...@@ -2417,6 +2417,8 @@ static int pxa_camera_probe(struct platform_device *pdev)
dma_release_channel(pcdev->dma_chans[1]); dma_release_channel(pcdev->dma_chans[1]);
exit_free_dma_y: exit_free_dma_y:
dma_release_channel(pcdev->dma_chans[0]); dma_release_channel(pcdev->dma_chans[0]);
exit_notifier_cleanup:
v4l2_async_nf_cleanup(&pcdev->notifier);
return err; return err;
} }
......
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