media: i2c: imx290: Check for availability in probe()
authorBenjamin Bara <benjamin.bara@skidata.com>
Tue, 3 Sep 2024 14:54:34 +0000 (16:54 +0200)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Wed, 16 Oct 2024 07:32:36 +0000 (09:32 +0200)
Currently, the V4L2 subdevice is also created when the device is not
available/connected. From userspace perspective, there is no visible
difference between a working and not-working subdevice (except when
trying it out).

This commit adds a simple preparation step, which includes an
availability check, before the subdev is initialized.

Signed-off-by: Benjamin Bara <benjamin.bara@skidata.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/media/i2c/imx290.c

index 47cfb6a9e9b5bfca996264c65e9ec4e4ad85d759..49a5bf9c17dac1f980031b252765dc1be9265e21 100644 (file)
@@ -1589,6 +1589,16 @@ static int imx290_probe(struct i2c_client *client)
        pm_runtime_set_autosuspend_delay(dev, 1000);
        pm_runtime_use_autosuspend(dev);
 
+       /*
+        * Make sure the sensor is available, in STANDBY and not streaming
+        * before the V4L2 subdev is initialized.
+        */
+       ret = imx290_stop_streaming(imx290);
+       if (ret) {
+               ret = dev_err_probe(dev, ret, "Could not initialize device\n");
+               goto err_pm;
+       }
+
        /* Initialize the V4L2 subdev. */
        ret = imx290_subdev_init(imx290);
        if (ret)