All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] media: i2c: ov2659: speedup probe if no device connected
@ 2015-12-21 13:54 Grygorii Strashko
  2016-01-05 17:32 ` Lad, Prabhakar
  0 siblings, 1 reply; 2+ messages in thread
From: Grygorii Strashko @ 2015-12-21 13:54 UTC (permalink / raw)
  To: Lad, Prabhakar, Mauro Carvalho Chehab
  Cc: linux-media, linux-kernel, Grygorii Strashko, Benoit Parrot

The ov2659 driver performs device detection and initialization in the
following way:
 - send reset command REG_SOFTWARE_RESET
 - load array of predefined register's setting (~150 values)
 - read device version REG_SC_CHIP_ID_H/REG_SC_CHIP_ID_L
 - check version and exit if invalid.

As result, for not connected device there will be >~150 i2c transactions
executed before device version checking and exit (there are no
failures detected because ov2659 declared as I2C_CLIENT_SCCB and NACKs
are ignored in this case).

Let's fix that by checking the chip version first and start
initialization only if it's supported.

Cc: Benoit Parrot <bparrot@ti.com>
Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
---
 drivers/media/i2c/ov2659.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/media/i2c/ov2659.c b/drivers/media/i2c/ov2659.c
index 49109f4..9b7b78c 100644
--- a/drivers/media/i2c/ov2659.c
+++ b/drivers/media/i2c/ov2659.c
@@ -1321,10 +1321,6 @@ static int ov2659_detect(struct v4l2_subdev *sd)
 	}
 	usleep_range(1000, 2000);
 
-	ret = ov2659_init(sd, 0);
-	if (ret < 0)
-		return ret;
-
 	/* Check sensor revision */
 	ret = ov2659_read(client, REG_SC_CHIP_ID_H, &pid);
 	if (!ret)
@@ -1338,8 +1334,10 @@ static int ov2659_detect(struct v4l2_subdev *sd)
 			dev_err(&client->dev,
 				"Sensor detection failed (%04X, %d)\n",
 				id, ret);
-		else
+		else {
 			dev_info(&client->dev, "Found OV%04X sensor\n", id);
+			ret = ov2659_init(sd, 0);
+		}
 	}
 
 	return ret;
-- 
2.6.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] media: i2c: ov2659: speedup probe if no device connected
  2015-12-21 13:54 [PATCH] media: i2c: ov2659: speedup probe if no device connected Grygorii Strashko
@ 2016-01-05 17:32 ` Lad, Prabhakar
  0 siblings, 0 replies; 2+ messages in thread
From: Lad, Prabhakar @ 2016-01-05 17:32 UTC (permalink / raw)
  To: Grygorii Strashko; +Cc: Mauro Carvalho Chehab, linux-media, LKML, Benoit Parrot

On Mon, Dec 21, 2015 at 1:54 PM, Grygorii Strashko
<grygorii.strashko@ti.com> wrote:
> The ov2659 driver performs device detection and initialization in the
> following way:
>  - send reset command REG_SOFTWARE_RESET
>  - load array of predefined register's setting (~150 values)
>  - read device version REG_SC_CHIP_ID_H/REG_SC_CHIP_ID_L
>  - check version and exit if invalid.
>
> As result, for not connected device there will be >~150 i2c transactions
> executed before device version checking and exit (there are no
> failures detected because ov2659 declared as I2C_CLIENT_SCCB and NACKs
> are ignored in this case).
>
> Let's fix that by checking the chip version first and start
> initialization only if it's supported.
>
> Cc: Benoit Parrot <bparrot@ti.com>
> Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>

Acked-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>

Cheers,
--Prabhakar Lad

> ---
>  drivers/media/i2c/ov2659.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/media/i2c/ov2659.c b/drivers/media/i2c/ov2659.c
> index 49109f4..9b7b78c 100644
> --- a/drivers/media/i2c/ov2659.c
> +++ b/drivers/media/i2c/ov2659.c
> @@ -1321,10 +1321,6 @@ static int ov2659_detect(struct v4l2_subdev *sd)
>         }
>         usleep_range(1000, 2000);
>
> -       ret = ov2659_init(sd, 0);
> -       if (ret < 0)
> -               return ret;
> -
>         /* Check sensor revision */
>         ret = ov2659_read(client, REG_SC_CHIP_ID_H, &pid);
>         if (!ret)
> @@ -1338,8 +1334,10 @@ static int ov2659_detect(struct v4l2_subdev *sd)
>                         dev_err(&client->dev,
>                                 "Sensor detection failed (%04X, %d)\n",
>                                 id, ret);
> -               else
> +               else {
>                         dev_info(&client->dev, "Found OV%04X sensor\n", id);
> +                       ret = ov2659_init(sd, 0);
> +               }
>         }
>
>         return ret;
> --
> 2.6.4
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-01-05 17:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-21 13:54 [PATCH] media: i2c: ov2659: speedup probe if no device connected Grygorii Strashko
2016-01-05 17:32 ` Lad, Prabhakar

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.