diff mbox

media/tvp514x: recognize the error case in tvp514x_read_reg()

Message ID 20090922183429.GA8585@Chamillionaire.breakpoint.cc (mailing list archive)
State Accepted
Delegated to: Douglas Landgraf
Headers show

Commit Message

Sebastian Andrzej Siewior Sept. 22, 2009, 6:34 p.m. UTC
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>

i2c_smbus_read_byte_data() returns a negative value on error. It is very
likely to be != -1 (-EPERM).

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
Noticed by strange results during signal beeing pending.

 drivers/media/video/tvp514x.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Comments

Vaibhav Hiremath Sept. 23, 2009, 11:41 p.m. UTC | #1
> -----Original Message-----
> From: Sebastian Andrzej Siewior [mailto:bigeasy@linutronix.de]
> Sent: Wednesday, September 23, 2009 12:04 AM
> To: Mauro Carvalho Chehab
> Cc: linux-media@vger.kernel.org; Hiremath, Vaibhav; Roel Kluin
> Subject: [PATCH] media/tvp514x: recognize the error case in
> tvp514x_read_reg()
> 
> From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> 
> i2c_smbus_read_byte_data() returns a negative value on error. It is
> very
> likely to be != -1 (-EPERM).
> 
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
> Noticed by strange results during signal beeing pending.
> 
>  drivers/media/video/tvp514x.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/media/video/tvp514x.c
> b/drivers/media/video/tvp514x.c
> index 2443726..26b4e71 100644
> --- a/drivers/media/video/tvp514x.c
> +++ b/drivers/media/video/tvp514x.c
> @@ -272,7 +272,7 @@ static int tvp514x_read_reg(struct v4l2_subdev
> *sd, u8 reg)
>  read_again:
> 
>  	err = i2c_smbus_read_byte_data(client, reg);
> -	if (err == -1) {
> +	if (err < 0) {
>  		if (retry <= I2C_RETRY_COUNT) {
>  			v4l2_warn(sd, "Read: retry ... %d\n", retry);
>  			retry++;
[Hiremath, Vaibhav] Thanks Sebastian, good catch.

Acked by Vaibhav Hiremath.

Hans, can you apply this patch to your tree.

Thanks,
Vaibhav
> --
> 1.6.3.3
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/media/video/tvp514x.c b/drivers/media/video/tvp514x.c
index 2443726..26b4e71 100644
--- a/drivers/media/video/tvp514x.c
+++ b/drivers/media/video/tvp514x.c
@@ -272,7 +272,7 @@  static int tvp514x_read_reg(struct v4l2_subdev *sd, u8 reg)
 read_again:
 
 	err = i2c_smbus_read_byte_data(client, reg);
-	if (err == -1) {
+	if (err < 0) {
 		if (retry <= I2C_RETRY_COUNT) {
 			v4l2_warn(sd, "Read: retry ... %d\n", retry);
 			retry++;