diff mbox

[3/3] ov2640: simplify single register writes

Message ID 1348402042-3538-3-git-send-email-fschaefer.oss@googlemail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Frank Schäfer Sept. 23, 2012, 12:07 p.m. UTC
Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
---
 drivers/media/i2c/soc_camera/ov2640.c |   21 ++++++++++++---------
 1 Datei geändert, 12 Zeilen hinzugefügt(+), 9 Zeilen entfernt(-)

Comments

Frank Schäfer Sept. 23, 2012, 6:25 p.m. UTC | #1
Am 23.09.2012 15:07, schrieb Frank Schäfer:
> Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
> ---
>  drivers/media/i2c/soc_camera/ov2640.c |   21 ++++++++++++---------
>  1 Datei geändert, 12 Zeilen hinzugefügt(+), 9 Zeilen entfernt(-)
>
> diff --git a/drivers/media/i2c/soc_camera/ov2640.c b/drivers/media/i2c/soc_camera/ov2640.c
> index 182d5a1..70b222f 100644
> --- a/drivers/media/i2c/soc_camera/ov2640.c
> +++ b/drivers/media/i2c/soc_camera/ov2640.c
> @@ -639,17 +639,23 @@ static struct ov2640_priv *to_ov2640(const struct i2c_client *client)
>  			    subdev);
>  }
>  
> +static int ov2640_write_single(struct i2c_client *client, u8  reg, u8 val)
> +{
> +	int ret;
> +
> +	ret = i2c_smbus_write_byte_data(client, reg, val);
> +	dev_vdbg(&client->dev, "write: 0x%02x, 0x%02x", reg, val);
> +
> +	return ret;

Uhm... wait ! Of course we can get rid of int ret.
Will resend in a minute...

Regards,
Frank

> +}
> +
>  static int ov2640_write_array(struct i2c_client *client,
>  			      const struct regval_list *vals)
>  {
>  	int ret;
>  
>  	while ((vals->reg_num != 0xff) || (vals->value != 0xff)) {
> -		ret = i2c_smbus_write_byte_data(client,
> -						vals->reg_num, vals->value);
> -		dev_vdbg(&client->dev, "array: 0x%02x, 0x%02x",
> -			 vals->reg_num, vals->value);
> -
> +		ret = ov2640_write_single(client, vals->reg_num, vals->value);
>  		if (ret < 0)
>  			return ret;
>  		vals++;
> @@ -704,13 +710,10 @@ static int ov2640_s_ctrl(struct v4l2_ctrl *ctrl)
>  	struct v4l2_subdev *sd =
>  		&container_of(ctrl->handler, struct ov2640_priv, hdl)->subdev;
>  	struct i2c_client  *client = v4l2_get_subdevdata(sd);
> -	struct regval_list regval;
>  	int ret;
>  	u8 val;
>  
> -	regval.reg_num = BANK_SEL;
> -	regval.value = BANK_SEL_SENS;
> -	ret = ov2640_write_array(client, &regval);
> +	ret = ov2640_write_single(client, BANK_SEL, BANK_SEL_SENS);
>  	if (ret < 0)
>  		return ret;
>  

--
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/i2c/soc_camera/ov2640.c b/drivers/media/i2c/soc_camera/ov2640.c
index 182d5a1..70b222f 100644
--- a/drivers/media/i2c/soc_camera/ov2640.c
+++ b/drivers/media/i2c/soc_camera/ov2640.c
@@ -639,17 +639,23 @@  static struct ov2640_priv *to_ov2640(const struct i2c_client *client)
 			    subdev);
 }
 
+static int ov2640_write_single(struct i2c_client *client, u8  reg, u8 val)
+{
+	int ret;
+
+	ret = i2c_smbus_write_byte_data(client, reg, val);
+	dev_vdbg(&client->dev, "write: 0x%02x, 0x%02x", reg, val);
+
+	return ret;
+}
+
 static int ov2640_write_array(struct i2c_client *client,
 			      const struct regval_list *vals)
 {
 	int ret;
 
 	while ((vals->reg_num != 0xff) || (vals->value != 0xff)) {
-		ret = i2c_smbus_write_byte_data(client,
-						vals->reg_num, vals->value);
-		dev_vdbg(&client->dev, "array: 0x%02x, 0x%02x",
-			 vals->reg_num, vals->value);
-
+		ret = ov2640_write_single(client, vals->reg_num, vals->value);
 		if (ret < 0)
 			return ret;
 		vals++;
@@ -704,13 +710,10 @@  static int ov2640_s_ctrl(struct v4l2_ctrl *ctrl)
 	struct v4l2_subdev *sd =
 		&container_of(ctrl->handler, struct ov2640_priv, hdl)->subdev;
 	struct i2c_client  *client = v4l2_get_subdevdata(sd);
-	struct regval_list regval;
 	int ret;
 	u8 val;
 
-	regval.reg_num = BANK_SEL;
-	regval.value = BANK_SEL_SENS;
-	ret = ov2640_write_array(client, &regval);
+	ret = ov2640_write_single(client, BANK_SEL, BANK_SEL_SENS);
 	if (ret < 0)
 		return ret;