[media] v4l: use i2c_smbus_read_word_swapped
authorJonathan Cameron <jic23@cam.ac.uk>
Fri, 21 Oct 2011 12:30:25 +0000 (09:30 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Mon, 7 Nov 2011 12:39:29 +0000 (10:39 -0200)
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>
drivers/media/video/mt9m001.c
drivers/media/video/mt9m111.c
drivers/media/video/mt9t031.c
drivers/media/video/mt9v022.c
drivers/media/video/mt9v032.c

index 63ae5c61c9bf9af4f63c32f0ed6ed3e513206d1a..9f3ffc7bf9d29a60830db6436de552fefceacd9b 100644 (file)
@@ -108,14 +108,13 @@ static struct mt9m001 *to_mt9m001(const struct i2c_client *client)
 
 static int reg_read(struct i2c_client *client, const u8 reg)
 {
-       s32 data = i2c_smbus_read_word_data(client, reg);
-       return data < 0 ? data : swab16(data);
+       return i2c_smbus_read_word_swapped(client, reg);
 }
 
 static int reg_write(struct i2c_client *client, const u8 reg,
                     const u16 data)
 {
-       return i2c_smbus_write_word_data(client, reg, swab16(data));
+       return i2c_smbus_write_word_swapped(client, reg, data);
 }
 
 static int reg_set(struct i2c_client *client, const u8 reg,
index f023cc092c2b8ea6d435daaf77e802ae74ef0ad3..59bfe39ba5854b898d46588ef28af4acaa273009 100644 (file)
@@ -210,7 +210,7 @@ static int reg_page_map_set(struct i2c_client *client, const u16 reg)
        if (page > 2)
                return -EINVAL;
 
-       ret = i2c_smbus_write_word_data(client, MT9M111_PAGE_MAP, swab16(page));
+       ret = i2c_smbus_write_word_swapped(client, MT9M111_PAGE_MAP, page);
        if (!ret)
                mt9m111->lastpage = page;
        return ret;
@@ -222,7 +222,7 @@ static int mt9m111_reg_read(struct i2c_client *client, const u16 reg)
 
        ret = reg_page_map_set(client, reg);
        if (!ret)
-               ret = swab16(i2c_smbus_read_word_data(client, reg & 0xff));
+               ret = i2c_smbus_read_word_swapped(client, reg & 0xff);
 
        dev_dbg(&client->dev, "read  reg.%03x -> %04x\n", reg, ret);
        return ret;
@@ -235,8 +235,7 @@ static int mt9m111_reg_write(struct i2c_client *client, const u16 reg,
 
        ret = reg_page_map_set(client, reg);
        if (!ret)
-               ret = i2c_smbus_write_word_data(client, reg & 0xff,
-                                               swab16(data));
+               ret = i2c_smbus_write_word_swapped(client, reg & 0xff, data);
        dev_dbg(&client->dev, "write reg.%03x = %04x -> %d\n", reg, data, ret);
        return ret;
 }
index 7ee84cc578b9d2d018358bb6d1a44b7415fdb994..198298cf2f817762b0bea7c73878a6c7b8fce924 100644 (file)
@@ -89,14 +89,13 @@ static struct mt9t031 *to_mt9t031(const struct i2c_client *client)
 
 static int reg_read(struct i2c_client *client, const u8 reg)
 {
-       s32 data = i2c_smbus_read_word_data(client, reg);
-       return data < 0 ? data : swab16(data);
+       return i2c_smbus_read_word_swapped(client, reg);
 }
 
 static int reg_write(struct i2c_client *client, const u8 reg,
                     const u16 data)
 {
-       return i2c_smbus_write_word_data(client, reg, swab16(data));
+       return i2c_smbus_write_word_swapped(client, reg, data);
 }
 
 static int reg_set(struct i2c_client *client, const u8 reg,
index b6a29f7de82cf60ff6cbf21c878db52f43afbd78..c5c67ec8fd78fa1d1199435f3ed634c3e389965a 100644 (file)
@@ -129,14 +129,13 @@ static struct mt9v022 *to_mt9v022(const struct i2c_client *client)
 
 static int reg_read(struct i2c_client *client, const u8 reg)
 {
-       s32 data = i2c_smbus_read_word_data(client, reg);
-       return data < 0 ? data : swab16(data);
+       return i2c_smbus_read_word_swapped(client, reg);
 }
 
 static int reg_write(struct i2c_client *client, const u8 reg,
                     const u16 data)
 {
-       return i2c_smbus_write_word_data(client, reg, swab16(data));
+       return i2c_smbus_write_word_swapped(client, reg, data);
 }
 
 static int reg_set(struct i2c_client *client, const u8 reg,
index c64e1dc4cb4e52585f3518564cf334d2b2bf55ba..7906929f106ead2218ef112bb871ffae6a2ed81a 100644 (file)
@@ -138,10 +138,10 @@ static struct mt9v032 *to_mt9v032(struct v4l2_subdev *sd)
 
 static int mt9v032_read(struct i2c_client *client, const u8 reg)
 {
-       s32 data = i2c_smbus_read_word_data(client, reg);
+       s32 data = i2c_smbus_read_word_swapped(client, reg);
        dev_dbg(&client->dev, "%s: read 0x%04x from 0x%02x\n", __func__,
-               swab16(data), reg);
-       return data < 0 ? data : swab16(data);
+               data, reg);
+       return data;
 }
 
 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,
 {
        dev_dbg(&client->dev, "%s: writing 0x%04x to 0x%02x\n", __func__,
                data, reg);
-       return i2c_smbus_write_word_data(client, reg, swab16(data));
+       return i2c_smbus_write_word_swapped(client, reg, data);
 }
 
 static int mt9v032_set_chip_control(struct mt9v032 *mt9v032, u16 clear, u16 set)