All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] media: ov8856: Modify ov8856 register reading function to be simplified
@ 2019-01-15  9:36 Ben Kao
  0 siblings, 0 replies; only message in thread
From: Ben Kao @ 2019-01-15  9:36 UTC (permalink / raw)
  To: linux-media; +Cc: sakari.ailus, andy.yeh, tfiga, Ben Kao

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>
---
 drivers/media/i2c/ov8856.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/media/i2c/ov8856.c b/drivers/media/i2c/ov8856.c
index c0d4408..dbf1095 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;
-- 
2.7.4


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2019-01-15  9:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-15  9:36 [PATCH] media: ov8856: Modify ov8856 register reading function to be simplified Ben Kao

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.