public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@cam.ac.uk>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: linux-media@vger.kernel.org, khali@linux-fr.org, kernel@pengutronix.de
Subject: Re: [PATCH] v4l: mt9p031/mt9t001: Use i2c_smbus_{read|write}_word_swapped()
Date: Mon, 24 Oct 2011 09:26:43 +0100	[thread overview]
Message-ID: <4EA52143.50806@cam.ac.uk> (raw)
In-Reply-To: <201110221057.54573.laurent.pinchart@ideasonboard.com>

On 10/22/11 09:57, Laurent Pinchart wrote:
> The MT9P031 and MT9T001 sensors transfer 16-bit data on the I2C bus in
> swapped order. Let the I2C core handle byte order by using the
> i2c_smbus_{read|write}_word_swapped() functions.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Jonathan Cameron <jic23@cam.ac.uk>
> ---
>  drivers/media/video/mt9p031.c |    5 ++---
>  drivers/media/video/mt9t001.c |    5 ++---
>  2 files changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/media/video/mt9p031.c b/drivers/media/video/mt9p031.c
> index 5cfa39f..aa01c4b 100644
> --- a/drivers/media/video/mt9p031.c
> +++ b/drivers/media/video/mt9p031.c
> @@ -131,13 +131,12 @@ static struct mt9p031 *to_mt9p031(struct v4l2_subdev *sd)
>  
>  static int mt9p031_read(struct i2c_client *client, u8 reg)
>  {
> -	s32 data = i2c_smbus_read_word_data(client, reg);
> -	return data < 0 ? data : be16_to_cpu(data);
> +	return i2c_smbus_read_word_swapped(client, reg);
>  }
>  
>  static int mt9p031_write(struct i2c_client *client, u8 reg, u16 data)
>  {
> -	return i2c_smbus_write_word_data(client, reg, cpu_to_be16(data));
> +	return i2c_smbus_write_word_swapped(client, reg, data);
>  }
>  
>  static int mt9p031_set_output_control(struct mt9p031 *mt9p031, u16 clear,
> diff --git a/drivers/media/video/mt9t001.c b/drivers/media/video/mt9t001.c
> index cac1416..2ea6a08 100644
> --- a/drivers/media/video/mt9t001.c
> +++ b/drivers/media/video/mt9t001.c
> @@ -132,13 +132,12 @@ static inline struct mt9t001 *to_mt9t001(struct v4l2_subdev *sd)
>  
>  static int mt9t001_read(struct i2c_client *client, u8 reg)
>  {
> -	s32 data = i2c_smbus_read_word_data(client, reg);
> -	return data < 0 ? data : be16_to_cpu(data);
> +	return i2c_smbus_read_word_swapped(client, reg);
>  }
>  
>  static int mt9t001_write(struct i2c_client *client, u8 reg, u16 data)
>  {
> -	return i2c_smbus_write_word_data(client, reg, cpu_to_be16(data));
> +	return i2c_smbus_write_word_swapped(client, reg, data);
>  }
>  
>  static int mt9t001_set_output_control(struct mt9t001 *mt9t001, u16 clear,


  reply	other threads:[~2011-10-24  8:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20111021144652.6aa97c8f@endymion.delvare>
     [not found] ` <1319203825-23247-1-git-send-email-jic23@cam.ac.uk>
2011-10-22  8:57   ` [PATCH V2] v4l: use i2c_smbus_read_word_swapped Laurent Pinchart
2011-10-22  8:57   ` [PATCH] v4l: mt9p031/mt9t001: Use i2c_smbus_{read|write}_word_swapped() Laurent Pinchart
2011-10-24  8:26     ` Jonathan Cameron [this message]
2011-10-27 14:56     ` Jean Delvare

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=4EA52143.50806@cam.ac.uk \
    --to=jic23@cam.ac.uk \
    --cc=kernel@pengutronix.de \
    --cc=khali@linux-fr.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    /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