]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
media: i2c: og01a1b: Fix V4L2 subdevice data initialization on probe
authorVladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
Thu, 26 Feb 2026 13:37:34 +0000 (15:37 +0200)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Wed, 11 Mar 2026 00:05:35 +0000 (01:05 +0100)
It's necessary to finalize the camera sensor subdevice initialization on
driver probe and clean V4L2 subdevice data up on error paths and driver
removal.

The change fixes a previously reported by v4l2-compliance issue of
the failed VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT test:

  fail: v4l2-test-controls.cpp(1104): subscribe event for control 'User Controls' failed

Fixes: 472377febf84 ("media: Add a driver for the og01a1b camera sensor")
Signed-off-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/media/i2c/og01a1b.c

index c7184de6251ae69f98ca7547e220911988a525a7..7b892b26203c0444b48a3aef612d6bfd2a6e5250 100644 (file)
@@ -1042,6 +1042,7 @@ static void og01a1b_remove(struct i2c_client *client)
        struct og01a1b *og01a1b = to_og01a1b(sd);
 
        v4l2_async_unregister_subdev(sd);
+       v4l2_subdev_cleanup(&og01a1b->sd);
        media_entity_cleanup(&sd->entity);
        v4l2_ctrl_handler_free(sd->ctrl_handler);
        pm_runtime_disable(og01a1b->dev);
@@ -1153,11 +1154,18 @@ static int og01a1b_probe(struct i2c_client *client)
                goto probe_error_v4l2_ctrl_handler_free;
        }
 
+       ret = v4l2_subdev_init_finalize(&og01a1b->sd);
+       if (ret < 0) {
+               dev_err_probe(og01a1b->dev, ret,
+                             "failed to finalize subdevice init\n");
+               goto probe_error_media_entity_cleanup;
+       }
+
        ret = v4l2_async_register_subdev_sensor(&og01a1b->sd);
        if (ret < 0) {
                dev_err(og01a1b->dev, "failed to register V4L2 subdev: %d",
                        ret);
-               goto probe_error_media_entity_cleanup;
+               goto probe_error_v4l2_subdev_cleanup;
        }
 
        /* Enable runtime PM and turn off the device */
@@ -1167,6 +1175,9 @@ static int og01a1b_probe(struct i2c_client *client)
 
        return 0;
 
+probe_error_v4l2_subdev_cleanup:
+       v4l2_subdev_cleanup(&og01a1b->sd);
+
 probe_error_media_entity_cleanup:
        media_entity_cleanup(&og01a1b->sd.entity);