diff options
author | Jonathan Cameron <jic23@cam.ac.uk> | 2011-10-21 08:30:25 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-11-07 07:39:29 -0500 |
commit | 3f8770454b82c166662201a8966476f4538cbfeb (patch) | |
tree | 4092eed169d90ef91790936fa58629e8738a2bab | |
parent | 8f4ffb1d4752ebce153e88266ac1164e8ecc5854 (diff) |
[media] v4l: use i2c_smbus_read_word_swapped
Function ensures that error codes don't get mangled.
Dependant on:
which is working it's way through the i2c tree.
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Acked-by: Jean Delvare <khali@linux-fr.org>
Acked-by: Robert Jarzmik <robert.jarzmik@free.fr>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/video/mt9m001.c | 5 | ||||
-rw-r--r-- | drivers/media/video/mt9m111.c | 7 | ||||
-rw-r--r-- | drivers/media/video/mt9t031.c | 5 | ||||
-rw-r--r-- | drivers/media/video/mt9v022.c | 5 | ||||
-rw-r--r-- | drivers/media/video/mt9v032.c | 8 |
5 files changed, 13 insertions, 17 deletions
diff --git a/drivers/media/video/mt9m001.c b/drivers/media/video/mt9m001.c index 63ae5c61c9bf..9f3ffc7bf9d2 100644 --- a/drivers/media/video/mt9m001.c +++ b/drivers/media/video/mt9m001.c | |||
@@ -108,14 +108,13 @@ static struct mt9m001 *to_mt9m001(const struct i2c_client *client) | |||
108 | 108 | ||
109 | static int reg_read(struct i2c_client *client, const u8 reg) | 109 | static int reg_read(struct i2c_client *client, const u8 reg) |
110 | { | 110 | { |
111 | s32 data = i2c_smbus_read_word_data(client, reg); | 111 | return i2c_smbus_read_word_swapped(client, reg); |
112 | return data < 0 ? data : swab16(data); | ||
113 | } | 112 | } |
114 | 113 | ||
115 | static int reg_write(struct i2c_client *client, const u8 reg, | 114 | static int reg_write(struct i2c_client *client, const u8 reg, |
116 | const u16 data) | 115 | const u16 data) |
117 | { | 116 | { |
118 | return i2c_smbus_write_word_data(client, reg, swab16(data)); | 117 | return i2c_smbus_write_word_swapped(client, reg, data); |
119 | } | 118 | } |
120 | 119 | ||
121 | static int reg_set(struct i2c_client *client, const u8 reg, | 120 | static int reg_set(struct i2c_client *client, const u8 reg, |
diff --git a/drivers/media/video/mt9m111.c b/drivers/media/video/mt9m111.c index f023cc092c2b..59bfe39ba585 100644 --- a/drivers/media/video/mt9m111.c +++ b/drivers/media/video/mt9m111.c | |||
@@ -210,7 +210,7 @@ static int reg_page_map_set(struct i2c_client *client, const u16 reg) | |||
210 | if (page > 2) | 210 | if (page > 2) |
211 | return -EINVAL; | 211 | return -EINVAL; |
212 | 212 | ||
213 | ret = i2c_smbus_write_word_data(client, MT9M111_PAGE_MAP, swab16(page)); | 213 | ret = i2c_smbus_write_word_swapped(client, MT9M111_PAGE_MAP, page); |
214 | if (!ret) | 214 | if (!ret) |
215 | mt9m111->lastpage = page; | 215 | mt9m111->lastpage = page; |
216 | return ret; | 216 | return ret; |
@@ -222,7 +222,7 @@ static int mt9m111_reg_read(struct i2c_client *client, const u16 reg) | |||
222 | 222 | ||
223 | ret = reg_page_map_set(client, reg); | 223 | ret = reg_page_map_set(client, reg); |
224 | if (!ret) | 224 | if (!ret) |
225 | ret = swab16(i2c_smbus_read_word_data(client, reg & 0xff)); | 225 | ret = i2c_smbus_read_word_swapped(client, reg & 0xff); |
226 | 226 | ||
227 | dev_dbg(&client->dev, "read reg.%03x -> %04x\n", reg, ret); | 227 | dev_dbg(&client->dev, "read reg.%03x -> %04x\n", reg, ret); |
228 | return ret; | 228 | return ret; |
@@ -235,8 +235,7 @@ static int mt9m111_reg_write(struct i2c_client *client, const u16 reg, | |||
235 | 235 | ||
236 | ret = reg_page_map_set(client, reg); | 236 | ret = reg_page_map_set(client, reg); |
237 | if (!ret) | 237 | if (!ret) |
238 | ret = i2c_smbus_write_word_data(client, reg & 0xff, | 238 | ret = i2c_smbus_write_word_swapped(client, reg & 0xff, data); |
239 | swab16(data)); | ||
240 | dev_dbg(&client->dev, "write reg.%03x = %04x -> %d\n", reg, data, ret); | 239 | dev_dbg(&client->dev, "write reg.%03x = %04x -> %d\n", reg, data, ret); |
241 | return ret; | 240 | return ret; |
242 | } | 241 | } |
diff --git a/drivers/media/video/mt9t031.c b/drivers/media/video/mt9t031.c index 7ee84cc578b9..198298cf2f81 100644 --- a/drivers/media/video/mt9t031.c +++ b/drivers/media/video/mt9t031.c | |||
@@ -89,14 +89,13 @@ static struct mt9t031 *to_mt9t031(const struct i2c_client *client) | |||
89 | 89 | ||
90 | static int reg_read(struct i2c_client *client, const u8 reg) | 90 | static int reg_read(struct i2c_client *client, const u8 reg) |
91 | { | 91 | { |
92 | s32 data = i2c_smbus_read_word_data(client, reg); | 92 | return i2c_smbus_read_word_swapped(client, reg); |
93 | return data < 0 ? data : swab16(data); | ||
94 | } | 93 | } |
95 | 94 | ||
96 | static int reg_write(struct i2c_client *client, const u8 reg, | 95 | static int reg_write(struct i2c_client *client, const u8 reg, |
97 | const u16 data) | 96 | const u16 data) |
98 | { | 97 | { |
99 | return i2c_smbus_write_word_data(client, reg, swab16(data)); | 98 | return i2c_smbus_write_word_swapped(client, reg, data); |
100 | } | 99 | } |
101 | 100 | ||
102 | static int reg_set(struct i2c_client *client, const u8 reg, | 101 | static int reg_set(struct i2c_client *client, const u8 reg, |
diff --git a/drivers/media/video/mt9v022.c b/drivers/media/video/mt9v022.c index b6a29f7de82c..c5c67ec8fd78 100644 --- a/drivers/media/video/mt9v022.c +++ b/drivers/media/video/mt9v022.c | |||
@@ -129,14 +129,13 @@ static struct mt9v022 *to_mt9v022(const struct i2c_client *client) | |||
129 | 129 | ||
130 | static int reg_read(struct i2c_client *client, const u8 reg) | 130 | static int reg_read(struct i2c_client *client, const u8 reg) |
131 | { | 131 | { |
132 | s32 data = i2c_smbus_read_word_data(client, reg); | 132 | return i2c_smbus_read_word_swapped(client, reg); |
133 | return data < 0 ? data : swab16(data); | ||
134 | } | 133 | } |
135 | 134 | ||
136 | static int reg_write(struct i2c_client *client, const u8 reg, | 135 | static int reg_write(struct i2c_client *client, const u8 reg, |
137 | const u16 data) | 136 | const u16 data) |
138 | { | 137 | { |
139 | return i2c_smbus_write_word_data(client, reg, swab16(data)); | 138 | return i2c_smbus_write_word_swapped(client, reg, data); |
140 | } | 139 | } |
141 | 140 | ||
142 | static int reg_set(struct i2c_client *client, const u8 reg, | 141 | static int reg_set(struct i2c_client *client, const u8 reg, |
diff --git a/drivers/media/video/mt9v032.c b/drivers/media/video/mt9v032.c index c64e1dc4cb4e..7906929f106e 100644 --- a/drivers/media/video/mt9v032.c +++ b/drivers/media/video/mt9v032.c | |||
@@ -138,10 +138,10 @@ static struct mt9v032 *to_mt9v032(struct v4l2_subdev *sd) | |||
138 | 138 | ||
139 | static int mt9v032_read(struct i2c_client *client, const u8 reg) | 139 | static int mt9v032_read(struct i2c_client *client, const u8 reg) |
140 | { | 140 | { |
141 | s32 data = i2c_smbus_read_word_data(client, reg); | 141 | s32 data = i2c_smbus_read_word_swapped(client, reg); |
142 | dev_dbg(&client->dev, "%s: read 0x%04x from 0x%02x\n", __func__, | 142 | dev_dbg(&client->dev, "%s: read 0x%04x from 0x%02x\n", __func__, |
143 | swab16(data), reg); | 143 | data, reg); |
144 | return data < 0 ? data : swab16(data); | 144 | return data; |
145 | } | 145 | } |
146 | 146 | ||
147 | static int mt9v032_write(struct i2c_client *client, const u8 reg, | 147 | static int mt9v032_write(struct i2c_client *client, const u8 reg, |
@@ -149,7 +149,7 @@ static int mt9v032_write(struct i2c_client *client, const u8 reg, | |||
149 | { | 149 | { |
150 | dev_dbg(&client->dev, "%s: writing 0x%04x to 0x%02x\n", __func__, | 150 | dev_dbg(&client->dev, "%s: writing 0x%04x to 0x%02x\n", __func__, |
151 | data, reg); | 151 | data, reg); |
152 | return i2c_smbus_write_word_data(client, reg, swab16(data)); | 152 | return i2c_smbus_write_word_swapped(client, reg, data); |
153 | } | 153 | } |
154 | 154 | ||
155 | static int mt9v032_set_chip_control(struct mt9v032 *mt9v032, u16 clear, u16 set) | 155 | static int mt9v032_set_chip_control(struct mt9v032 *mt9v032, u16 clear, u16 set) |