[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240902-imx290-avail-v3-6-b32a12799fed@skidata.com>
Date: Mon, 02 Sep 2024 17:57:31 +0200
From: bbara93@...il.com
To: Mauro Carvalho Chehab <mchehab@...nel.org>,
Manivannan Sadhasivam <manivannan.sadhasivam@...aro.org>,
Sakari Ailus <sakari.ailus@...ux.intel.com>
Cc: Hans de Goede <hdegoede@...hat.com>,
Laurent Pinchart <laurent.pinchart@...asonboard.com>,
Alexander Stein <alexander.stein@...tq-group.com>,
linux-media@...r.kernel.org, linux-kernel@...r.kernel.org,
Benjamin Bara <benjamin.bara@...data.com>
Subject: [PATCH v3 6/7] media: i2c: imx290: Check for availability in
probe()
From: Benjamin Bara <benjamin.bara@...data.com>
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 availability check before starting with the
subdev initialization to error out instead.
Signed-off-by: Benjamin Bara <benjamin.bara@...data.com>
---
Changes since v2:
- the new 1/8 is split out
- use dev_err_probe() (thx Laurent)
---
drivers/media/i2c/imx290.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/media/i2c/imx290.c b/drivers/media/i2c/imx290.c
index 9610e9fd2059..6b292bbb0856 100644
--- a/drivers/media/i2c/imx290.c
+++ b/drivers/media/i2c/imx290.c
@@ -1571,6 +1571,7 @@ static int imx290_probe(struct i2c_client *client)
{
struct device *dev = &client->dev;
struct imx290 *imx290;
+ u64 val;
int ret;
imx290 = devm_kzalloc(dev, sizeof(*imx290), GFP_KERNEL);
@@ -1631,6 +1632,17 @@ 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 before V4L2 subdev init. */
+ ret = cci_read(imx290->regmap, IMX290_STANDBY, &val, NULL);
+ if (ret) {
+ ret = dev_err_probe(dev, -ENODEV, "Failed to detect sensor\n");
+ goto err_pm;
+ }
+ if (val != IMX290_STANDBY_STANDBY) {
+ ret = dev_err_probe(dev, -ENODEV, "Sensor is not in standby\n");
+ goto err_pm;
+ }
+
/* Initialize the V4L2 subdev. */
ret = imx290_subdev_init(imx290);
if (ret)
--
2.46.0
Powered by blists - more mailing lists