media: i2c: ov2659: Fix sensor detection to actually fail when device is not present
authorBenoit Parrot <bparrot@ti.com>
Mon, 30 Sep 2019 13:06:38 +0000 (10:06 -0300)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Tue, 1 Oct 2019 20:34:12 +0000 (17:34 -0300)
Make sure that if the expected sensor device id register
is not recognized properly the failure is propagated
up so devices are not left partially initialized.

Signed-off-by: Benoit Parrot <bparrot@ti.com>
Signed-off-by: Jyri Sarha <jsarha@ti.com>
Acked-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
drivers/media/i2c/ov2659.c

index 17573257097d253798939cc1cc86f3c8375c04ed..efbe6dc720e2d3343b721a4f27f2486d6caa8cba 100644 (file)
@@ -1330,11 +1330,12 @@ static int ov2659_detect(struct v4l2_subdev *sd)
                unsigned short id;
 
                id = OV265X_ID(pid, ver);
                unsigned short id;
 
                id = OV265X_ID(pid, ver);
-               if (id != OV2659_ID)
+               if (id != OV2659_ID) {
                        dev_err(&client->dev,
                                "Sensor detection failed (%04X, %d)\n",
                                id, ret);
                        dev_err(&client->dev,
                                "Sensor detection failed (%04X, %d)\n",
                                id, ret);
-               else {
+                       ret = -ENODEV;
+               } else {
                        dev_info(&client->dev, "Found OV%04X sensor\n", id);
                        ret = ov2659_init(sd, 0);
                }
                        dev_info(&client->dev, "Found OV%04X sensor\n", id);
                        ret = ov2659_init(sd, 0);
                }