[PATCH] media: ov8856: Modify ov8856 register reading function to be simplified

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 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




[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux