[media] v4l: mt9p031/mt9t001: Use i2c_smbus_{read|write}_word_swapped()
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Sat, 22 Oct 2011 07:57:54 +0000 (04:57 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Mon, 7 Nov 2011 13:27:29 +0000 (11:27 -0200)
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>
Acked-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/mt9p031.c
drivers/media/video/mt9t001.c

index 73c068993f050cce24eb408d2cbf7e745791c667..93c3ec7426e85ce14b83d8380c7c008abeb5505c 100644 (file)
@@ -132,13 +132,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,
index 08074b8a2736ca75a8bcdd6a26512536e584cf36..cd81d04a529e2ec9eb1d10fd9eb2c80f502830c4 100644 (file)
@@ -133,13 +133,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,