Skip to contentSkip to conversation

tvp7002: Don't update device->streaming if write to register fails

PATCH In review Axel Lin 2 participants 2 messages Aug 16, 2014 Media (V4L/DVB)

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 tvp7002: Don't update device->streaming if write to register fails

This ensures device->streaming has correct status.

---
 drivers/media/i2c/tvp7002.c | 21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)
drivers/media/i2c/tvp7002.c +8 -13
index 11f2387..51bac76 100644
@@ -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;
 }
 
 /*
Signature · 1 line
1.9.1
Acked-by on v1 1/1
#1 lore raw

Hi Axel,

Thanks for the patch!

Quoted 3 lines · Axel Lin

This ensures device->streaming has correct status.

Regards,
--Prabhakar Lad

Quoted 47 lines
---
 drivers/media/i2c/tvp7002.c | 21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)
drivers/media/i2c/tvp7002.c +8 -14
index 11f2387..51bac76 100644
@@ -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