diff options
-rw-r--r-- | drivers/media/platform/mxc/capture/ov5640_mipi.c | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/drivers/media/platform/mxc/capture/ov5640_mipi.c b/drivers/media/platform/mxc/capture/ov5640_mipi.c index 5847fbeb5524..f91ee983c196 100644 --- a/drivers/media/platform/mxc/capture/ov5640_mipi.c +++ b/drivers/media/platform/mxc/capture/ov5640_mipi.c @@ -2097,27 +2097,32 @@ static s32 ov5640_write_reg(u16 reg, u8 val) static s32 ov5640_read_reg(u16 reg, u8 *val) { - u8 au8RegBuf[2] = {0}; - u8 u8RdVal = 0; + struct sensor_data *sensor = &ov5640_data; + struct i2c_client *client = sensor->i2c_client; + struct i2c_msg msgs[2]; + u8 buf[2]; + int ret; - au8RegBuf[0] = reg >> 8; - au8RegBuf[1] = reg & 0xff; + buf[0] = reg >> 8; + buf[1] = reg & 0xff; + msgs[0].addr = client->addr; + msgs[0].flags = 0; + msgs[0].len = 2; + msgs[0].buf = buf; - if (2 != i2c_master_send(ov5640_data.i2c_client, au8RegBuf, 2)) { - pr_err("%s(mipi):write reg error:reg=%x\n", - __func__, reg); - return -1; - } + msgs[1].addr = client->addr; + msgs[1].flags = I2C_M_RD; + msgs[1].len = 1; + msgs[1].buf = buf; - if (1 != i2c_master_recv(ov5640_data.i2c_client, &u8RdVal, 1)) { - pr_err("%s(mipi):read reg error:reg=%x,val=%x\n", - __func__, reg, u8RdVal); - return -1; + ret = i2c_transfer(client->adapter, msgs, 2); + if (ret < 0) { + pr_err("%s(mipi):reg=%x ret=%d\n", __func__, reg, ret); + return ret; } - - *val = u8RdVal; - pr_debug("%s(mipi):reg=%x,val=%x\n", __func__, reg, u8RdVal); - return u8RdVal; + *val = buf[0]; + pr_debug("%s(mipi):reg=%x,val=%x\n", __func__, reg, buf[0]); + return buf[0]; } static int prev_sysclk, prev_HTS; |