diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2014-05-26 15:31:28 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <m.chehab@samsung.com> | 2014-07-22 09:00:08 -0400 |
commit | e35ce2e4b2c7657e9e23b618c861c258ce4a57bf (patch) | |
tree | 2a50919143d370dad88a0c629733273c3ff6d393 /drivers/media/i2c | |
parent | 385dded8066aec9cb78cfbcc842532dff7946704 (diff) |
[media] tvp5150: Use i2c_smbus_(read|write)_byte_data
X-Patchwork-Delegate: mchehab@redhat.com
Replace the custom I2C read/write implementation with SMBUS functions to
simplify the driver.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Diffstat (limited to 'drivers/media/i2c')
-rw-r--r-- | drivers/media/i2c/tvp5150.c | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c index 937e48b3b734..193e7d6c29c8 100644 --- a/drivers/media/i2c/tvp5150.c +++ b/drivers/media/i2c/tvp5150.c | |||
@@ -56,38 +56,29 @@ static inline struct v4l2_subdev *to_sd(struct v4l2_ctrl *ctrl) | |||
56 | static int tvp5150_read(struct v4l2_subdev *sd, unsigned char addr) | 56 | static int tvp5150_read(struct v4l2_subdev *sd, unsigned char addr) |
57 | { | 57 | { |
58 | struct i2c_client *c = v4l2_get_subdevdata(sd); | 58 | struct i2c_client *c = v4l2_get_subdevdata(sd); |
59 | unsigned char buffer[1]; | ||
60 | int rc; | 59 | int rc; |
61 | struct i2c_msg msg[] = { | 60 | |
62 | { .addr = c->addr, .flags = 0, | 61 | rc = i2c_smbus_read_byte_data(c, addr); |
63 | .buf = &addr, .len = 1 }, | 62 | if (rc < 0) { |
64 | { .addr = c->addr, .flags = I2C_M_RD, | 63 | v4l2_err(sd, "i2c i/o error: rc == %d\n", rc); |
65 | .buf = buffer, .len = 1 } | 64 | return rc; |
66 | }; | ||
67 | |||
68 | rc = i2c_transfer(c->adapter, msg, 2); | ||
69 | if (rc < 0 || rc != 2) { | ||
70 | v4l2_err(sd, "i2c i/o error: rc == %d (should be 2)\n", rc); | ||
71 | return rc < 0 ? rc : -EIO; | ||
72 | } | 65 | } |
73 | 66 | ||
74 | v4l2_dbg(2, debug, sd, "tvp5150: read 0x%02x = 0x%02x\n", addr, buffer[0]); | 67 | v4l2_dbg(2, debug, sd, "tvp5150: read 0x%02x = 0x%02x\n", addr, rc); |
75 | 68 | ||
76 | return (buffer[0]); | 69 | return rc; |
77 | } | 70 | } |
78 | 71 | ||
79 | static inline void tvp5150_write(struct v4l2_subdev *sd, unsigned char addr, | 72 | static inline void tvp5150_write(struct v4l2_subdev *sd, unsigned char addr, |
80 | unsigned char value) | 73 | unsigned char value) |
81 | { | 74 | { |
82 | struct i2c_client *c = v4l2_get_subdevdata(sd); | 75 | struct i2c_client *c = v4l2_get_subdevdata(sd); |
83 | unsigned char buffer[2]; | ||
84 | int rc; | 76 | int rc; |
85 | 77 | ||
86 | buffer[0] = addr; | 78 | v4l2_dbg(2, debug, sd, "tvp5150: writing 0x%02x 0x%02x\n", addr, value); |
87 | buffer[1] = value; | 79 | rc = i2c_smbus_write_byte_data(c, addr, value); |
88 | v4l2_dbg(2, debug, sd, "tvp5150: writing 0x%02x 0x%02x\n", buffer[0], buffer[1]); | 80 | if (rc < 0) |
89 | if (2 != (rc = i2c_master_send(c, buffer, 2))) | 81 | v4l2_dbg(0, debug, sd, "i2c i/o error: rc == %d\n", rc); |
90 | v4l2_dbg(0, debug, sd, "i2c i/o error: rc == %d (should be 2)\n", rc); | ||
91 | } | 82 | } |
92 | 83 | ||
93 | static void dump_reg_range(struct v4l2_subdev *sd, char *s, u8 init, | 84 | static void dump_reg_range(struct v4l2_subdev *sd, char *s, u8 init, |