@@ -2299,6 +2299,10 @@ static int pxa_camera_probe(struct platform_device *pdev)
pcdev->irq = irq;
pcdev->base = base;
+ err = v4l2_device_register(&pdev->dev, &pcdev->v4l2_dev);
+ if (err)
+ return err;
+
v4l2_async_nf_init(&pcdev->notifier);
pcdev->res = res;
pcdev->pdata = pdev->dev.platform_data;
@@ -2316,10 +2320,10 @@ static int pxa_camera_probe(struct platform_device *pdev)
} else if (pdev->dev.of_node) {
err = pxa_camera_pdata_from_dt(&pdev->dev, pcdev);
} else {
- return -ENODEV;
+ err = -ENODEV;
}
if (err < 0)
- return err;
+ goto exit_v4l2_device_unregister;
if (!(pcdev->platform_flags & (PXA_CAMERA_DATAWIDTH_8 |
PXA_CAMERA_DATAWIDTH_9 | PXA_CAMERA_DATAWIDTH_10))) {
@@ -2385,13 +2389,10 @@ static int pxa_camera_probe(struct platform_device *pdev)
pxa_camera_activate(pcdev);
platform_set_drvdata(pdev, pcdev);
- err = v4l2_device_register(&pdev->dev, &pcdev->v4l2_dev);
- if (err)
- goto exit_deactivate;
err = pxa_camera_init_videobuf2(pcdev);
if (err)
- goto exit_v4l2_device_unregister;
+ goto exit_deactivate;
/* request irq */
err = devm_request_irq(&pdev->dev, pcdev->irq, pxa_camera_irq, 0,
@@ -2404,11 +2405,9 @@ static int pxa_camera_probe(struct platform_device *pdev)
pcdev->notifier.ops = &pxa_camera_sensor_ops;
err = v4l2_async_nf_register(&pcdev->v4l2_dev, &pcdev->notifier);
if (err)
- goto exit_v4l2_device_unregister;
+ goto exit_deactivate;
return 0;
-exit_v4l2_device_unregister:
- v4l2_device_unregister(&pcdev->v4l2_dev);
exit_deactivate:
pxa_camera_deactivate(pcdev);
tasklet_kill(&pcdev->task_eof);
@@ -2420,6 +2419,8 @@ static int pxa_camera_probe(struct platform_device *pdev)
dma_release_channel(pcdev->dma_chans[0]);
exit_notifier_cleanup:
v4l2_async_nf_cleanup(&pcdev->notifier);
+exit_v4l2_device_unregister:
+ v4l2_device_unregister(&pcdev->v4l2_dev);
return err;
}