Re: [PATCHv2 6/6] media: Convert struct i2c_msg initialization to C99 format
On Tue, Sep 18, 2012 at 3:26 PM, Venu Byravarasu vbyravar...@nvidia.com wrote: -Original Message- From: linux-kernel-ow...@vger.kernel.org [mailto:linux-kernel- ow...@vger.kernel.org] On Behalf Of Shubhrajyoti D Sent: Tuesday, September 18, 2012 3:21 PM To: linux-media@vger.kernel.org Cc: linux-ker...@vger.kernel.org; julia.law...@lip6.fr; Shubhrajyoti D Subject: [PATCHv2 6/6] media: Convert struct i2c_msg initialization to C99 format Convert the struct i2c_msg initialization to C99 format. This makes maintaining and editing the code simpler. Also helps once other fields like transferred are added in future. Signed-off-by: Shubhrajyoti D shubhrajy...@ti.com --- drivers/media/i2c/msp3400-driver.c | 42 ++- 1 files changed, 36 insertions(+), 6 deletions(-) diff --git a/drivers/media/i2c/msp3400-driver.c b/drivers/media/i2c/msp3400-driver.c index aeb22be..b8cef8d 100644 --- a/drivers/media/i2c/msp3400-driver.c +++ b/drivers/media/i2c/msp3400-driver.c @@ -119,12 +119,32 @@ int msp_reset(struct i2c_client *client) static u8 write[3] = { I2C_MSP_DSP + 1, 0x00, 0x1e }; u8 read[2]; struct i2c_msg reset[2] = { - { client-addr, I2C_M_IGNORE_NAK, 3, reset_off }, - { client-addr, I2C_M_IGNORE_NAK, 3, reset_on }, + { + .addr = client-addr, + .flags = I2C_M_IGNORE_NAK, + .len = 3, + .buf = reset_off + }, + { + .addr = client-addr, + .flags = I2C_M_IGNORE_NAK, + .len = 3, + .buf = reset_on + }, }; struct i2c_msg test[2] = { - { client-addr, 0,3, write }, - { client-addr, I2C_M_RD, 2, read }, + { + .addr = client-addr, + .flags = 0, Does flags not contain 0 by default? It does however I felt that 0 means write so letting it be explicit. In case a removal is preferred that's doable too however felt it is more readable this way. -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCHv2 6/6] media: Convert struct i2c_msg initialization to C99 format
-Original Message- From: Shubhrajyoti Datta [mailto:omaplinuxker...@gmail.com] Sent: Tuesday, September 18, 2012 3:30 PM To: Venu Byravarasu Cc: Shubhrajyoti D; linux-media@vger.kernel.org; linux- ker...@vger.kernel.org; julia.law...@lip6.fr Subject: Re: [PATCHv2 6/6] media: Convert struct i2c_msg initialization to C99 format struct i2c_msg test[2] = { - { client-addr, 0,3, write }, - { client-addr, I2C_M_RD, 2, read }, + { + .addr = client-addr, + .flags = 0, Does flags not contain 0 by default? It does however I felt that 0 means write so letting it be explicit. In case a removal is preferred that's doable too however felt it is more readable this way. Though it adds readability, it carries an overhead of one write operation too. So, better to remove it. -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCHv2 6/6] media: Convert struct i2c_msg initialization to C99 format
On Tue 18 Sep 2012 03:02:42 AM PDT, Venu Byravarasu wrote: -Original Message- From: Shubhrajyoti Datta [mailto:omaplinuxker...@gmail.com] Sent: Tuesday, September 18, 2012 3:30 PM To: Venu Byravarasu Cc: Shubhrajyoti D; linux-media@vger.kernel.org; linux- ker...@vger.kernel.org; julia.law...@lip6.fr Subject: Re: [PATCHv2 6/6] media: Convert struct i2c_msg initialization to C99 format struct i2c_msg test[2] = { - { client-addr, 0,3, write }, - { client-addr, I2C_M_RD, 2, read }, + { + .addr = client-addr, + .flags = 0, Does flags not contain 0 by default? It does however I felt that 0 means write so letting it be explicit. In case a removal is preferred that's doable too however felt it is more readable this way. Though it adds readability, it carries an overhead of one write operation too. So, better to remove it. Partially initialized structs will have their unmentioned members initialized to zero. So there is no overhead of one write operation by mentioning it explicitly. -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html