diff options
author | Sakari Ailus <sakari.ailus@linux.intel.com> | 2023-04-28 13:14:46 +0200 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@kernel.org> | 2023-08-10 07:58:31 +0200 |
commit | 6e1e132e0038a2a4bce11ff1ad0db3b4564042c9 (patch) | |
tree | 3e9ff54eeb760cdc83e467564bb9f130fe9cc8c4 /drivers/media/platform/intel | |
parent | 1e3454582e11e0108ad0743529461181f8476741 (diff) | |
download | lwn-6e1e132e0038a2a4bce11ff1ad0db3b4564042c9.tar.gz lwn-6e1e132e0038a2a4bce11ff1ad0db3b4564042c9.zip |
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: Sakari 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: Mauro Carvalho Chehab <mchehab@kernel.org>
Diffstat (limited to 'drivers/media/platform/intel')
-rw-r--r-- | drivers/media/platform/intel/pxa_camera.c | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/drivers/media/platform/intel/pxa_camera.c b/drivers/media/platform/intel/pxa_camera.c index 1544102554da..2453bf58f92d 100644 --- a/drivers/media/platform/intel/pxa_camera.c +++ b/drivers/media/platform/intel/pxa_camera.c @@ -2274,13 +2274,6 @@ static int pxa_camera_probe(struct platform_device *pdev) int irq; 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); if (irq < 0) return -ENODEV; @@ -2295,6 +2288,16 @@ static int pxa_camera_probe(struct platform_device *pdev) if (IS_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); pcdev->res = res; pcdev->pdata = pdev->dev.platform_data; @@ -2344,14 +2347,12 @@ static int pxa_camera_probe(struct platform_device *pdev) spin_lock_init(&pcdev->lock); mutex_init(&pcdev->mlock); - pcdev->irq = irq; - pcdev->base = base; - /* request dma */ pcdev->dma_chans[0] = dma_request_chan(&pdev->dev, "CI_Y"); if (IS_ERR(pcdev->dma_chans[0])) { 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"); @@ -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); pxa_camera_activate(pcdev); @@ -2397,16 +2390,23 @@ static int pxa_camera_probe(struct platform_device *pdev) err = pxa_camera_init_videobuf2(pcdev); 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; err = v4l2_async_nf_register(&pcdev->v4l2_dev, &pcdev->notifier); if (err) - goto exit_notifier_cleanup; + goto exit_v4l2_device_unregister; return 0; -exit_notifier_cleanup: - v4l2_async_nf_cleanup(&pcdev->notifier); +exit_v4l2_device_unregister: v4l2_device_unregister(&pcdev->v4l2_dev); exit_deactivate: pxa_camera_deactivate(pcdev); @@ -2417,6 +2417,8 @@ exit_free_dma_u: dma_release_channel(pcdev->dma_chans[1]); exit_free_dma_y: dma_release_channel(pcdev->dma_chans[0]); +exit_notifier_cleanup: + v4l2_async_nf_cleanup(&pcdev->notifier); return err; } |