media: renesas: vsp1: Initialize control handler after subdev
authorLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Mon, 13 Nov 2023 16:41:44 +0000 (18:41 +0200)
committerLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Wed, 19 Jun 2024 22:36:49 +0000 (01:36 +0300)
Some VSP modules initialize their control handler after initializing the
subdev, while some initialize it before. This makes the code
inconsistent and more error prone. Standardize on control initialization
after initializing the subdev.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
drivers/media/platform/renesas/vsp1/vsp1_hgo.c
drivers/media/platform/renesas/vsp1/vsp1_hgt.c

index 0ea87014a701d6c288b19ff3d0de419cf782588a..2c8ce7175a4e7259515c46019df8a9f97d2f63c7 100644 (file)
@@ -192,6 +192,16 @@ struct vsp1_hgo *vsp1_hgo_create(struct vsp1_device *vsp1)
        if (hgo == NULL)
                return ERR_PTR(-ENOMEM);
 
+       /* Initialize the video device and queue for statistics data. */
+       ret = vsp1_histogram_init(vsp1, &hgo->histo, VSP1_ENTITY_HGO, "hgo",
+                                 &hgo_entity_ops, hgo_mbus_formats,
+                                 ARRAY_SIZE(hgo_mbus_formats),
+                                 HGO_DATA_SIZE, V4L2_META_FMT_VSP1_HGO);
+       if (ret < 0) {
+               vsp1_entity_destroy(&hgo->histo.entity);
+               return ERR_PTR(ret);
+       }
+
        /* Initialize the control handler. */
        v4l2_ctrl_handler_init(&hgo->ctrls.handler,
                               vsp1->info->gen >= 3 ? 2 : 1);
@@ -207,15 +217,5 @@ struct vsp1_hgo *vsp1_hgo_create(struct vsp1_device *vsp1)
 
        hgo->histo.entity.subdev.ctrl_handler = &hgo->ctrls.handler;
 
-       /* Initialize the video device and queue for statistics data. */
-       ret = vsp1_histogram_init(vsp1, &hgo->histo, VSP1_ENTITY_HGO, "hgo",
-                                 &hgo_entity_ops, hgo_mbus_formats,
-                                 ARRAY_SIZE(hgo_mbus_formats),
-                                 HGO_DATA_SIZE, V4L2_META_FMT_VSP1_HGO);
-       if (ret < 0) {
-               vsp1_entity_destroy(&hgo->histo.entity);
-               return ERR_PTR(ret);
-       }
-
        return hgo;
 }
index 496354c8df0eb28179b4da04135c211d1fc52572..858f330d44fa448c691d7445990803724d71fdb6 100644 (file)
@@ -191,12 +191,6 @@ struct vsp1_hgt *vsp1_hgt_create(struct vsp1_device *vsp1)
        if (hgt == NULL)
                return ERR_PTR(-ENOMEM);
 
-       /* Initialize the control handler. */
-       v4l2_ctrl_handler_init(&hgt->ctrls, 1);
-       v4l2_ctrl_new_custom(&hgt->ctrls, &hgt_hue_areas, NULL);
-
-       hgt->histo.entity.subdev.ctrl_handler = &hgt->ctrls;
-
        /* Initialize the video device and queue for statistics data. */
        ret = vsp1_histogram_init(vsp1, &hgt->histo, VSP1_ENTITY_HGT, "hgt",
                                  &hgt_entity_ops, hgt_mbus_formats,
@@ -207,6 +201,12 @@ struct vsp1_hgt *vsp1_hgt_create(struct vsp1_device *vsp1)
                return ERR_PTR(ret);
        }
 
+       /* Initialize the control handler. */
+       v4l2_ctrl_handler_init(&hgt->ctrls, 1);
+       v4l2_ctrl_new_custom(&hgt->ctrls, &hgt_hue_areas, NULL);
+
+       hgt->histo.entity.subdev.ctrl_handler = &hgt->ctrls;
+
        v4l2_ctrl_handler_setup(&hgt->ctrls);
 
        return hgt;