aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2011-10-22 03:57:54 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-11-07 08:27:29 -0500
commitc27e3050378ec0d96d964cbf18746a30ad00ab9f (patch)
tree9521555d4d322e88ecd6767b0a1913fa11309579
parentcfb128ed0768320c2d0e43cf781c8eaa622876b6 (diff)
[media] v4l: mt9p031/mt9t001: Use i2c_smbus_{read|write}_word_swapped()
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>
-rw-r--r--drivers/media/video/mt9p031.c5
-rw-r--r--drivers/media/video/mt9t001.c5
2 files changed, 4 insertions, 6 deletions
diff --git a/drivers/media/video/mt9p031.c b/drivers/media/video/mt9p031.c
index 73c068993f05..93c3ec7426e8 100644
--- a/drivers/media/video/mt9p031.c
+++ b/drivers/media/video/mt9p031.c
@@ -132,13 +132,12 @@ static struct mt9p031 *to_mt9p031(struct v4l2_subdev *sd)
132 132
133static int mt9p031_read(struct i2c_client *client, u8 reg) 133static int mt9p031_read(struct i2c_client *client, u8 reg)
134{ 134{
135 s32 data = i2c_smbus_read_word_data(client, reg); 135 return i2c_smbus_read_word_swapped(client, reg);
136 return data < 0 ? data : be16_to_cpu(data);
137} 136}
138 137
139static int mt9p031_write(struct i2c_client *client, u8 reg, u16 data) 138static int mt9p031_write(struct i2c_client *client, u8 reg, u16 data)
140{ 139{
141 return i2c_smbus_write_word_data(client, reg, cpu_to_be16(data)); 140 return i2c_smbus_write_word_swapped(client, reg, data);
142} 141}
143 142
144static int mt9p031_set_output_control(struct mt9p031 *mt9p031, u16 clear, 143static 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 08074b8a2736..cd81d04a529e 100644
--- a/drivers/media/video/mt9t001.c
+++ b/drivers/media/video/mt9t001.c
@@ -133,13 +133,12 @@ static inline struct mt9t001 *to_mt9t001(struct v4l2_subdev *sd)
133 133
134static int mt9t001_read(struct i2c_client *client, u8 reg) 134static int mt9t001_read(struct i2c_client *client, u8 reg)
135{ 135{
136 s32 data = i2c_smbus_read_word_data(client, reg); 136 return i2c_smbus_read_word_swapped(client, reg);
137 return data < 0 ? data : be16_to_cpu(data);
138} 137}
139 138
140static int mt9t001_write(struct i2c_client *client, u8 reg, u16 data) 139static int mt9t001_write(struct i2c_client *client, u8 reg, u16 data)
141{ 140{
142 return i2c_smbus_write_word_data(client, reg, cpu_to_be16(data)); 141 return i2c_smbus_write_word_swapped(client, reg, data);
143} 142}
144 143
145static int mt9t001_set_output_control(struct mt9t001 *mt9t001, u16 clear, 144static int mt9t001_set_output_control(struct mt9t001 *mt9t001, u16 clear,