Commit 8de531b0 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

[media] tvp5150: make read operations atomic

Instead of using two I2C operations between write and read,
use just one i2c_transfer. That allows I2C mutexes to not
let any other I2C transfer between the two.
Reviewed-by: default avatarFrank Schäfer <fschaefer.oss@googlemail.com>
Tested-by: default avatarFrank Schäfer <fschaefer.oss@googlemail.com>
Signed-off-by: default avatarMauro Carvalho Chehab <m.chehab@samsung.com>
parent f7d40eea
...@@ -58,21 +58,17 @@ static int tvp5150_read(struct v4l2_subdev *sd, unsigned char addr) ...@@ -58,21 +58,17 @@ static int tvp5150_read(struct v4l2_subdev *sd, unsigned char addr)
struct i2c_client *c = v4l2_get_subdevdata(sd); struct i2c_client *c = v4l2_get_subdevdata(sd);
unsigned char buffer[1]; unsigned char buffer[1];
int rc; int rc;
struct i2c_msg msg[] = {
buffer[0] = addr; { .addr = c->addr, .flags = 0,
.buf = &addr, .len = 1 },
rc = i2c_master_send(c, buffer, 1); { .addr = c->addr, .flags = I2C_M_RD,
if (rc < 0) { .buf = buffer, .len = 1 }
v4l2_err(sd, "i2c i/o error: rc == %d (should be 1)\n", rc); };
return rc;
} rc = i2c_transfer(c->adapter, msg, 2);
if (rc < 0 || rc != 2) {
msleep(10); v4l2_err(sd, "i2c i/o error: rc == %d (should be 2)\n", rc);
return rc < 0 ? rc : -EIO;
rc = i2c_master_recv(c, buffer, 1);
if (rc < 0) {
v4l2_err(sd, "i2c i/o error: rc == %d (should be 1)\n", rc);
return rc;
} }
v4l2_dbg(2, debug, sd, "tvp5150: read 0x%02x = 0x%02x\n", addr, buffer[0]); v4l2_dbg(2, debug, sd, "tvp5150: read 0x%02x = 0x%02x\n", addr, buffer[0]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment