Linux Media Controller development
 help / color / mirror / Atom feed
* [PATCH] [media] tvp7002: Don't update device->streaming if write to register fails
@ 2014-08-16  6:57 Axel Lin
  2014-08-16 10:05 ` Prabhakar Lad
  0 siblings, 1 reply; 2+ messages in thread
From: Axel Lin @ 2014-08-16  6:57 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Laurent Pinchart, Hans Verkuil, Lad, Prabhakar, linux-media

This ensures device->streaming has correct status.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
 drivers/media/i2c/tvp7002.c | 21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/drivers/media/i2c/tvp7002.c b/drivers/media/i2c/tvp7002.c
index 11f2387..51bac76 100644
--- a/drivers/media/i2c/tvp7002.c
+++ b/drivers/media/i2c/tvp7002.c
@@ -775,25 +775,20 @@ static int tvp7002_enum_mbus_fmt(struct v4l2_subdev *sd, unsigned index,
 static int tvp7002_s_stream(struct v4l2_subdev *sd, int enable)
 {
 	struct tvp7002 *device = to_tvp7002(sd);
-	int error = 0;
+	int error;
 
 	if (device->streaming == enable)
 		return 0;
 
-	if (enable) {
-		/* Set output state on (low impedance means stream on) */
-		error = tvp7002_write(sd, TVP7002_MISC_CTL_2, 0x00);
-		device->streaming = enable;
-	} else {
-		/* Set output state off (high impedance means stream off) */
-		error = tvp7002_write(sd, TVP7002_MISC_CTL_2, 0x03);
-		if (error)
-			v4l2_dbg(1, debug, sd, "Unable to stop streaming\n");
-
-		device->streaming = enable;
+	/* low impedance: on, high impedance: off */
+	error = tvp7002_write(sd, TVP7002_MISC_CTL_2, enable ? 0x00 : 0x03);
+	if (error) {
+		v4l2_dbg(1, debug, sd, "Fail to set streaming\n");
+		return error;
 	}
 
-	return error;
+	device->streaming = enable;
+	return 0;
 }
 
 /*
-- 
1.9.1




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

* Re: [PATCH] [media] tvp7002: Don't update device->streaming if write to register fails
  2014-08-16  6:57 [PATCH] [media] tvp7002: Don't update device->streaming if write to register fails Axel Lin
@ 2014-08-16 10:05 ` Prabhakar Lad
  0 siblings, 0 replies; 2+ messages in thread
From: Prabhakar Lad @ 2014-08-16 10:05 UTC (permalink / raw)
  To: Axel Lin; +Cc: Mauro Carvalho Chehab, Laurent Pinchart, Hans Verkuil,
	linux-media

Hi Axel,

Thanks for the patch!

On Sat, Aug 16, 2014 at 7:57 AM, Axel Lin <axel.lin@ingics.com> wrote:
> This ensures device->streaming has correct status.
>
> Signed-off-by: Axel Lin <axel.lin@ingics.com>

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

Regards,
--Prabhakar Lad

> ---
>  drivers/media/i2c/tvp7002.c | 21 ++++++++-------------
>  1 file changed, 8 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/media/i2c/tvp7002.c b/drivers/media/i2c/tvp7002.c
> index 11f2387..51bac76 100644
> --- a/drivers/media/i2c/tvp7002.c
> +++ b/drivers/media/i2c/tvp7002.c
> @@ -775,25 +775,20 @@ static int tvp7002_enum_mbus_fmt(struct v4l2_subdev *sd, unsigned index,
>  static int tvp7002_s_stream(struct v4l2_subdev *sd, int enable)
>  {
>         struct tvp7002 *device = to_tvp7002(sd);
> -       int error = 0;
> +       int error;
>
>         if (device->streaming == enable)
>                 return 0;
>
> -       if (enable) {
> -               /* Set output state on (low impedance means stream on) */
> -               error = tvp7002_write(sd, TVP7002_MISC_CTL_2, 0x00);
> -               device->streaming = enable;
> -       } else {
> -               /* Set output state off (high impedance means stream off) */
> -               error = tvp7002_write(sd, TVP7002_MISC_CTL_2, 0x03);
> -               if (error)
> -                       v4l2_dbg(1, debug, sd, "Unable to stop streaming\n");
> -
> -               device->streaming = enable;
> +       /* low impedance: on, high impedance: off */
> +       error = tvp7002_write(sd, TVP7002_MISC_CTL_2, enable ? 0x00 : 0x03);
> +       if (error) {
> +               v4l2_dbg(1, debug, sd, "Fail to set streaming\n");
> +               return error;
>         }
>
> -       return error;
> +       device->streaming = enable;
> +       return 0;
>  }
>
>  /*
> --
> 1.9.1
>
>
>

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

end of thread, other threads:[~2014-08-16 10:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-16  6:57 [PATCH] [media] tvp7002: Don't update device->streaming if write to register fails Axel Lin
2014-08-16 10:05 ` Prabhakar Lad

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox