diff options
author | Ben Kao <ben.kao@intel.com> | 2019-01-15 07:36:07 -0200 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab+samsung@kernel.org> | 2019-01-25 10:46:03 -0200 |
commit | fa6527340141bfec061db2f2a9cca7f82584f94e (patch) | |
tree | a6d570291326a877e4fd98e761645ab87d8c0c0d /drivers | |
parent | 030f9f682e66ea3be214f673ca8ba53294eeecd2 (diff) | |
download | linux-fa6527340141bfec061db2f2a9cca7f82584f94e.tar.bz2 |
media: ov8856: Modify ov8856 register reading function to be simplified
We use put_unaligned_be16() to be simplified for setting register address
in ov8856_read_reg() and use sizeof() to be better suited for bytes
copying.
Signed-off-by: Ben Kao <ben.kao@intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/media/i2c/ov8856.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/media/i2c/ov8856.c b/drivers/media/i2c/ov8856.c index c0d44082c003..dbf1095b9440 100644 --- a/drivers/media/i2c/ov8856.c +++ b/drivers/media/i2c/ov8856.c @@ -605,16 +605,17 @@ static int ov8856_read_reg(struct ov8856 *ov8856, u16 reg, u16 len, u32 *val) { struct i2c_client *client = v4l2_get_subdevdata(&ov8856->sd); struct i2c_msg msgs[2]; - u8 addr_buf[2] = {reg >> 8, reg & 0xff}; - u8 data_buf[4] = {0, }; + u8 addr_buf[2]; + u8 data_buf[4] = {0}; int ret; if (len > 4) return -EINVAL; + put_unaligned_be16(reg, addr_buf); msgs[0].addr = client->addr; msgs[0].flags = 0; - msgs[0].len = ARRAY_SIZE(addr_buf); + msgs[0].len = sizeof(addr_buf); msgs[0].buf = addr_buf; msgs[1].addr = client->addr; msgs[1].flags = I2C_M_RD; |