[1/2] ov772x: bit mask operation fix on ov772x_mask_set.

Message ID u7i4rpxp9.wl%morimoto.kuninori@renesas.com (mailing list archive)
State Superseded, archived
Headers

Commit Message

Kuninori Morimoto Jan. 19, 2009, 12:53 a.m. UTC
  Signed-off-by: Kuninori Morimoto <morimoto.kuninori@renesas.com>
---
 drivers/media/video/ov772x.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
  

Comments

Guennadi Liakhovetski Jan. 19, 2009, 7:27 a.m. UTC | #1
Hi,

On Mon, 19 Jan 2009, Kuninori Morimoto wrote:

> Signed-off-by: Kuninori Morimoto <morimoto.kuninori@renesas.com>
> ---
>  drivers/media/video/ov772x.c |    5 ++++-
>  1 files changed, 4 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/media/video/ov772x.c b/drivers/media/video/ov772x.c
> index b75420d..c8e10d3 100644
> --- a/drivers/media/video/ov772x.c
> +++ b/drivers/media/video/ov772x.c
> @@ -566,8 +566,11 @@ static int ov772x_mask_set(struct i2c_client *client,
>  					  u8  set)
>  {
>  	s32 val = i2c_smbus_read_byte_data(client, command);
> +	if (val < 0)
> +		return val;
> +
>  	val &= ~mask;
> -	val |=  set;
> +	val |= (set & mask);

Please, remove superfluous parenthesis.

>  
>  	return i2c_smbus_write_byte_data(client, command, val);
>  }
> -- 

Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
--
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
  

Patch

diff --git a/drivers/media/video/ov772x.c b/drivers/media/video/ov772x.c
index b75420d..c8e10d3 100644
--- a/drivers/media/video/ov772x.c
+++ b/drivers/media/video/ov772x.c
@@ -566,8 +566,11 @@  static int ov772x_mask_set(struct i2c_client *client,
 					  u8  set)
 {
 	s32 val = i2c_smbus_read_byte_data(client, command);
+	if (val < 0)
+		return val;
+
 	val &= ~mask;
-	val |=  set;
+	val |= (set & mask);
 
 	return i2c_smbus_write_byte_data(client, command, val);
 }