Skip to content

Commit

Permalink
[media] v4l: use i2c_smbus_read_word_swapped
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jonathan Cameron authored and Mauro Carvalho Chehab committed Nov 7, 2011
1 parent 8f4ffb1 commit 3f87704
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 17 deletions.
5 changes: 2 additions & 3 deletions drivers/media/video/mt9m001.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 3 additions & 4 deletions drivers/media/video/mt9m111.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
}
Expand Down
5 changes: 2 additions & 3 deletions drivers/media/video/mt9t031.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 2 additions & 3 deletions drivers/media/video/mt9v022.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions drivers/media/video/mt9v032.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,18 +138,18 @@ 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,
const u16 data)
{
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)
Expand Down

0 comments on commit 3f87704

Please sign in to comment.