media: davinci: Init async notifier after registering V4L2 device
authorSakari Ailus <sakari.ailus@linux.intel.com>
Thu, 30 Mar 2023 09:31:13 +0000 (11:31 +0200)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Thu, 10 Aug 2023 05:58:31 +0000 (07:58 +0200)
Initialise the V4L2 async notifier after registering the V4L2 device, just
before parsing DT for async sub-devices. This way the device can be made
available to the V4L2 async framework from the notifier init time onwards.
A subsequent patch will add struct v4l2_device as an argument to
v4l2_async_nf_init().

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>
drivers/media/platform/ti/davinci/vpif_capture.c

index a63c9e5..10b13d8 100644 (file)
@@ -1608,18 +1608,12 @@ static __init int vpif_probe(struct platform_device *pdev)
        int res_idx = 0;
        int i, err;
 
-       pdev->dev.platform_data = vpif_capture_get_pdata(pdev);
-       if (!pdev->dev.platform_data) {
-               dev_warn(&pdev->dev, "Missing platform data.  Giving up.\n");
-               return -EINVAL;
-       }
-
        vpif_dev = &pdev->dev;
 
        err = initialize_vpif();
        if (err) {
                v4l2_err(vpif_dev->driver, "Error initializing vpif\n");
-               goto cleanup;
+               return err;
        }
 
        err = v4l2_device_register(vpif_dev, &vpif_obj.v4l2_dev);
@@ -1646,13 +1640,19 @@ static __init int vpif_probe(struct platform_device *pdev)
                        goto vpif_unregister;
        } while (++res_idx);
 
+       pdev->dev.platform_data = vpif_capture_get_pdata(pdev);
+       if (!pdev->dev.platform_data) {
+               dev_warn(&pdev->dev, "Missing platform data. Giving up.\n");
+               goto vpif_unregister;
+       }
+
        vpif_obj.config = pdev->dev.platform_data;
 
        subdev_count = vpif_obj.config->subdev_count;
        vpif_obj.sd = kcalloc(subdev_count, sizeof(*vpif_obj.sd), GFP_KERNEL);
        if (!vpif_obj.sd) {
                err = -ENOMEM;
-               goto vpif_unregister;
+               goto probe_subdev_out;
        }
 
        if (!vpif_obj.config->asd_sizes[0]) {
@@ -1695,14 +1695,13 @@ static __init int vpif_probe(struct platform_device *pdev)
        return 0;
 
 probe_subdev_out:
+       v4l2_async_nf_cleanup(&vpif_obj.notifier);
        /* free sub devices memory */
        kfree(vpif_obj.sd);
 vpif_unregister:
        v4l2_device_unregister(&vpif_obj.v4l2_dev);
 vpif_free:
        free_vpif_objs();
-cleanup:
-       v4l2_async_nf_cleanup(&vpif_obj.notifier);
 
        return err;
 }