public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: linux-media@vger.kernel.org
Cc: Mauro Carvalho Chehab <m.chehab@samsung.com>
Subject: Re: [PATCH] tvp5150: Use i2c_smbus_(read|write)_byte_data
Date: Thu, 17 Jul 2014 13:29:58 +0200	[thread overview]
Message-ID: <3203757.dfSHCQkonN@avalon> (raw)
In-Reply-To: <1401132688-5632-1-git-send-email-laurent.pinchart@ideasonboard.com>

Hi Mauro,

Ping ?

On Monday 26 May 2014 21:31:28 Laurent Pinchart wrote:
> Replace the custom I2C read/write implementation with SMBUS functions to
> simplify the driver.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  drivers/media/i2c/tvp5150.c | 31 +++++++++++--------------------
>  1 file changed, 11 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c
> index 937e48b..193e7d6 100644
> --- a/drivers/media/i2c/tvp5150.c
> +++ b/drivers/media/i2c/tvp5150.c
> @@ -56,38 +56,29 @@ static inline struct v4l2_subdev *to_sd(struct v4l2_ctrl
> *ctrl) static int tvp5150_read(struct v4l2_subdev *sd, unsigned char addr)
> {
>  	struct i2c_client *c = v4l2_get_subdevdata(sd);
> -	unsigned char buffer[1];
>  	int rc;
> -	struct i2c_msg msg[] = {
> -		{ .addr = c->addr, .flags = 0,
> -		  .buf = &addr, .len = 1 },
> -		{ .addr = c->addr, .flags = I2C_M_RD,
> -		  .buf = buffer, .len = 1 }
> -	};
> -
> -	rc = i2c_transfer(c->adapter, msg, 2);
> -	if (rc < 0 || rc != 2) {
> -		v4l2_err(sd, "i2c i/o error: rc == %d (should be 2)\n", rc);
> -		return rc < 0 ? rc : -EIO;
> +
> +	rc = i2c_smbus_read_byte_data(c, addr);
> +	if (rc < 0) {
> +		v4l2_err(sd, "i2c i/o error: rc == %d\n", rc);
> +		return rc;
>  	}
> 
> -	v4l2_dbg(2, debug, sd, "tvp5150: read 0x%02x = 0x%02x\n", addr,
> buffer[0]); +	v4l2_dbg(2, debug, sd, "tvp5150: read 0x%02x = 0x%02x\n",
> addr, rc);
> 
> -	return (buffer[0]);
> +	return rc;
>  }
> 
>  static inline void tvp5150_write(struct v4l2_subdev *sd, unsigned char
> addr, unsigned char value)
>  {
>  	struct i2c_client *c = v4l2_get_subdevdata(sd);
> -	unsigned char buffer[2];
>  	int rc;
> 
> -	buffer[0] = addr;
> -	buffer[1] = value;
> -	v4l2_dbg(2, debug, sd, "tvp5150: writing 0x%02x 0x%02x\n", buffer[0],
> buffer[1]); -	if (2 != (rc = i2c_master_send(c, buffer, 2)))
> -		v4l2_dbg(0, debug, sd, "i2c i/o error: rc == %d (should be 2)\n", 
rc);
> +	v4l2_dbg(2, debug, sd, "tvp5150: writing 0x%02x 0x%02x\n", addr, value);
> +	rc = i2c_smbus_write_byte_data(c, addr, value);
> +	if (rc < 0)
> +		v4l2_dbg(0, debug, sd, "i2c i/o error: rc == %d\n", rc);
>  }
> 
>  static void dump_reg_range(struct v4l2_subdev *sd, char *s, u8 init,

-- 
Regards,

Laurent Pinchart


      reply	other threads:[~2014-07-17 11:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-26 19:31 [PATCH] tvp5150: Use i2c_smbus_(read|write)_byte_data Laurent Pinchart
2014-07-17 11:29 ` Laurent Pinchart [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3203757.dfSHCQkonN@avalon \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=m.chehab@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox