* [PATCH V2] i2c-algo-pca: fix coding style issues in i2c-algo-pca.c
@ 2010-04-22 22:01 Farid Hammane
[not found] ` <1271973715-18331-1-git-send-email-farid.hammane-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: Farid Hammane @ 2010-04-22 22:01 UTC (permalink / raw)
To: w.sang-bIcnvbaLZ9MEGnE8C9+IrQ
Cc: khali-PUYAD+kWke1g9hUCZPvPmw, ben-linux-elnMNo+KYs3YtjvyW6yDsg,
Enrik.Berkhan-JJi787mZWgc, linux-i2c-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA, Farid Hammane
This patch fixes coding style issues found by checkpatch.pl.
i2c-algo-pca.c has been built successfully after applying this patch.
Signed-off-by: Farid Hammane <farid.hammane-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
drivers/i2c/algos/i2c-algo-pca.c | 36 ++++++++++++++++++------------------
1 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/drivers/i2c/algos/i2c-algo-pca.c b/drivers/i2c/algos/i2c-algo-pca.c
index dcdaf8e..ca817f8 100644
--- a/drivers/i2c/algos/i2c-algo-pca.c
+++ b/drivers/i2c/algos/i2c-algo-pca.c
@@ -37,15 +37,15 @@
static int i2c_debug;
-#define pca_outw(adap, reg, val) adap->write_byte(adap->data, reg, val)
-#define pca_inw(adap, reg) adap->read_byte(adap->data, reg)
+#define pca_outw(adap, reg, val) (adap->write_byte(adap->data, reg, val))
+#define pca_inw(adap, reg) (adap->read_byte(adap->data, reg))
#define pca_status(adap) pca_inw(adap, I2C_PCA_STA)
-#define pca_clock(adap) adap->i2c_clock
+#define pca_clock(adap) (adap->i2c_clock)
#define pca_set_con(adap, val) pca_outw(adap, I2C_PCA_CON, val)
#define pca_get_con(adap) pca_inw(adap, I2C_PCA_CON)
-#define pca_wait(adap) adap->wait_for_completion(adap->data)
-#define pca_reset(adap) adap->reset_chip(adap->data)
+#define pca_wait(adap) (adap->wait_for_completion(adap->data))
+#define pca_reset(adap) (adap->reset_chip(adap->data))
static void pca9665_reset(void *pd)
{
@@ -114,8 +114,8 @@ static int pca_address(struct i2c_algo_pca_data *adap,
int sta = pca_get_con(adap);
int addr;
- addr = ( (0x7f & msg->addr) << 1 );
- if (msg->flags & I2C_M_RD )
+ addr = ((0x7f & msg->addr) << 1);
+ if (msg->flags & I2C_M_RD)
addr |= 1;
DEB2("=== SLAVE ADDRESS %#04x+%c=%#04x\n",
msg->addr, msg->flags & I2C_M_RD ? 'R' : 'W', addr);
@@ -170,7 +170,7 @@ static int pca_rx_ack(struct i2c_algo_pca_data *adap,
sta &= ~(I2C_PCA_CON_STO|I2C_PCA_CON_STA|I2C_PCA_CON_SI|I2C_PCA_CON_AA);
- if ( ack )
+ if (ack)
sta |= I2C_PCA_CON_AA;
pca_set_con(adap, sta);
@@ -181,9 +181,9 @@ static int pca_xfer(struct i2c_adapter *i2c_adap,
struct i2c_msg *msgs,
int num)
{
- struct i2c_algo_pca_data *adap = i2c_adap->algo_data;
- struct i2c_msg *msg = NULL;
- int curmsg;
+ struct i2c_algo_pca_data *adap = i2c_adap->algo_data;
+ struct i2c_msg *msg = NULL;
+ int curmsg;
int numbytes = 0;
int state;
int ret;
@@ -202,21 +202,21 @@ static int pca_xfer(struct i2c_adapter *i2c_adap,
DEB1("{{{ XFER %d messages\n", num);
- if (i2c_debug>=2) {
+ if (i2c_debug >= 2) {
for (curmsg = 0; curmsg < num; curmsg++) {
int addr, i;
msg = &msgs[curmsg];
addr = (0x7f & msg->addr) ;
- if (msg->flags & I2C_M_RD )
+ if (msg->flags & I2C_M_RD)
printk(KERN_INFO " [%02d] RD %d bytes from %#02x [%#02x, ...]\n",
- curmsg, msg->len, addr, (addr<<1) | 1);
+ curmsg, msg->len, addr, (addr << 1) | 1);
else {
printk(KERN_INFO " [%02d] WR %d bytes to %#02x [%#02x%s",
- curmsg, msg->len, addr, addr<<1,
+ curmsg, msg->len, addr, addr << 1,
msg->len == 0 ? "" : ", ");
- for(i=0; i < msg->len; i++)
+ for (i = 0; i < msg->len; i++)
printk("%#04x%s", msg->buf[i], i == msg->len - 1 ? "" : ", ");
printk("]\n");
}
@@ -305,7 +305,7 @@ static int pca_xfer(struct i2c_adapter *i2c_adap,
goto out;
case 0x58: /* Data byte has been received; NOT ACK has been returned */
- if ( numbytes == msg->len - 1 ) {
+ if (numbytes == msg->len - 1) {
pca_rx_byte(adap, &msg->buf[numbytes], 0);
curmsg++; numbytes = 0;
if (curmsg == num)
@@ -352,7 +352,7 @@ static int pca_xfer(struct i2c_adapter *i2c_adap,
static u32 pca_func(struct i2c_adapter *adap)
{
- return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
+ return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
}
static const struct i2c_algorithm pca_algo = {
--
1.7.0
^ permalink raw reply related [flat|nested] 5+ messages in thread[parent not found: <1271973715-18331-1-git-send-email-farid.hammane-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH V2] i2c-algo-pca: fix coding style issues in i2c-algo-pca.c [not found] ` <1271973715-18331-1-git-send-email-farid.hammane-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2010-04-23 0:52 ` Wolfram Sang 2010-04-23 9:33 ` Jean Delvare 1 sibling, 0 replies; 5+ messages in thread From: Wolfram Sang @ 2010-04-23 0:52 UTC (permalink / raw) To: Farid Hammane Cc: khali-PUYAD+kWke1g9hUCZPvPmw, ben-linux-elnMNo+KYs3YtjvyW6yDsg, Enrik.Berkhan-JJi787mZWgc, linux-i2c-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA [-- Attachment #1: Type: text/plain, Size: 541 bytes --] On Fri, Apr 23, 2010 at 12:01:55AM +0200, Farid Hammane wrote: > This patch fixes coding style issues found by checkpatch.pl. > i2c-algo-pca.c has been built successfully after applying this patch. > > Signed-off-by: Farid Hammane <farid.hammane-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> Reviewed-by: Wolfram Sang <w.sang-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> Thanks! -- Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ | [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 197 bytes --] ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH V2] i2c-algo-pca: fix coding style issues in i2c-algo-pca.c [not found] ` <1271973715-18331-1-git-send-email-farid.hammane-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2010-04-23 0:52 ` Wolfram Sang @ 2010-04-23 9:33 ` Jean Delvare [not found] ` <20100423113326.3691bdd6-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org> 1 sibling, 1 reply; 5+ messages in thread From: Jean Delvare @ 2010-04-23 9:33 UTC (permalink / raw) To: Farid Hammane Cc: w.sang-bIcnvbaLZ9MEGnE8C9+IrQ, ben-linux-elnMNo+KYs3YtjvyW6yDsg, Enrik.Berkhan-JJi787mZWgc, linux-i2c-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA Hi Farid, Wolfram, On Fri, 23 Apr 2010 00:01:55 +0200, Farid Hammane wrote: > This patch fixes coding style issues found by checkpatch.pl. > i2c-algo-pca.c has been built successfully after applying this patch. > > Signed-off-by: Farid Hammane <farid.hammane-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > --- > drivers/i2c/algos/i2c-algo-pca.c | 36 ++++++++++++++++++------------------ > 1 files changed, 18 insertions(+), 18 deletions(-) > > diff --git a/drivers/i2c/algos/i2c-algo-pca.c b/drivers/i2c/algos/i2c-algo-pca.c > index dcdaf8e..ca817f8 100644 > --- a/drivers/i2c/algos/i2c-algo-pca.c > +++ b/drivers/i2c/algos/i2c-algo-pca.c > @@ -37,15 +37,15 @@ > > static int i2c_debug; > > -#define pca_outw(adap, reg, val) adap->write_byte(adap->data, reg, val) > -#define pca_inw(adap, reg) adap->read_byte(adap->data, reg) > +#define pca_outw(adap, reg, val) (adap->write_byte(adap->data, reg, val)) > +#define pca_inw(adap, reg) (adap->read_byte(adap->data, reg)) I'm confused by these changes. For one thing, macros which are shortcuts for function calls normally don't need surrounding parentheses. If checkpatch.pl complains about that, I would call it a false positive, unless someone can prove me wrong with a real-world case where these surrounding parentheses help. For another, macro _parameters_ normally need parentheses for each non-trivial use. I would thus expect the following to be correct: #define pca_outw(adap, reg, val) (adap)->write_byte((adap)->data, reg, val) #define pca_inw(adap, reg) (adap)->read_byte((adap)->data, reg) Or is it just me? > > #define pca_status(adap) pca_inw(adap, I2C_PCA_STA) > -#define pca_clock(adap) adap->i2c_clock > +#define pca_clock(adap) (adap->i2c_clock) > #define pca_set_con(adap, val) pca_outw(adap, I2C_PCA_CON, val) > #define pca_get_con(adap) pca_inw(adap, I2C_PCA_CON) > -#define pca_wait(adap) adap->wait_for_completion(adap->data) > -#define pca_reset(adap) adap->reset_chip(adap->data) > +#define pca_wait(adap) (adap->wait_for_completion(adap->data)) > +#define pca_reset(adap) (adap->reset_chip(adap->data)) Same here... I'm fine with all other changes. But checkpatch.pl spouts 2 more errors to me, which we've discussed before. I'm curious why you didn't fix them? Just replace each block of 8 spaces with one tab. ERROR: code indent should use tabs where possible #181: FILE: i2c/algos/i2c-algo-pca.c:181: + struct i2c_msg *msgs,$ ERROR: code indent should use tabs where possible #182: FILE: i2c/algos/i2c-algo-pca.c:182: + int num)$ -- Jean Delvare ^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <20100423113326.3691bdd6-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>]
* Re: [PATCH V2] i2c-algo-pca: fix coding style issues in i2c-algo-pca.c [not found] ` <20100423113326.3691bdd6-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org> @ 2010-04-24 14:07 ` Farid Hammane 2010-04-26 7:41 ` Wolfram Sang 1 sibling, 0 replies; 5+ messages in thread From: Farid Hammane @ 2010-04-24 14:07 UTC (permalink / raw) To: khali-PUYAD+kWke1g9hUCZPvPmw, w.sang-bIcnvbaLZ9MEGnE8C9+IrQ, ben-linux-elnMNo+KYs3YtjvyW6yDsg, Enrik.Berkhan-JJi787mZWgc, linux-i2c-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA Hi Jean, On Friday 23 April 2010 11:33:26 you wrote: > Hi Farid, Wolfram, > > On Fri, 23 Apr 2010 00:01:55 +0200, Farid Hammane wrote: > > This patch fixes coding style issues found by checkpatch.pl. > > i2c-algo-pca.c has been built successfully after applying this patch. > > > > Signed-off-by: Farid Hammane <farid.hammane-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > --- > > drivers/i2c/algos/i2c-algo-pca.c | 36 > > ++++++++++++++++++------------------ 1 files changed, 18 insertions(+), > > 18 deletions(-) > > > > diff --git a/drivers/i2c/algos/i2c-algo-pca.c > > b/drivers/i2c/algos/i2c-algo-pca.c index dcdaf8e..ca817f8 100644 > > --- a/drivers/i2c/algos/i2c-algo-pca.c > > +++ b/drivers/i2c/algos/i2c-algo-pca.c > > @@ -37,15 +37,15 @@ > > > > static int i2c_debug; > > > > -#define pca_outw(adap, reg, val) adap->write_byte(adap->data, reg, val) > > -#define pca_inw(adap, reg) adap->read_byte(adap->data, reg) > > +#define pca_outw(adap, reg, val) (adap->write_byte(adap->data, reg, > > val)) +#define pca_inw(adap, reg) (adap->read_byte(adap->data, reg)) > > I'm confused by these changes. For one thing, macros which are > shortcuts for function calls normally don't need surrounding > parentheses. If checkpatch.pl complains about that, I would call it a > false positive, unless someone can prove me wrong with a real-world > case where these surrounding parentheses help. > > For another, macro _parameters_ normally need parentheses for each > non-trivial use. I would thus expect the following to be correct: > > #define pca_outw(adap, reg, val) (adap)->write_byte((adap)->data, reg, val) > #define pca_inw(adap, reg) (adap)->read_byte((adap)->data, reg) > > Or is it just me? You are right ! This will be deleted from the patch. > > > #define pca_status(adap) pca_inw(adap, I2C_PCA_STA) > > -#define pca_clock(adap) adap->i2c_clock > > +#define pca_clock(adap) (adap->i2c_clock) > > #define pca_set_con(adap, val) pca_outw(adap, I2C_PCA_CON, val) > > #define pca_get_con(adap) pca_inw(adap, I2C_PCA_CON) > > -#define pca_wait(adap) adap->wait_for_completion(adap->data) > > -#define pca_reset(adap) adap->reset_chip(adap->data) > > +#define pca_wait(adap) (adap->wait_for_completion(adap->data)) > > +#define pca_reset(adap) (adap->reset_chip(adap->data)) > > Same here... > > I'm fine with all other changes. But checkpatch.pl spouts 2 more errors > to me, which we've discussed before. I'm curious why you didn't fix > them? Just replace each block of 8 spaces with one tab. I thought you expected just one tab and spaces. You said : "Better use tab + spaces and align on the opening parenthesis. What checkpatch.pl complains about here isn't the alignment, it's the use of more than 8 consecutive spaces." I understood here : "don't care about this warning !" So, I'll fix it. > > ERROR: code indent should use tabs where possible > #181: FILE: i2c/algos/i2c-algo-pca.c:181: > + struct i2c_msg *msgs,$ > > ERROR: code indent should use tabs where possible > #182: FILE: i2c/algos/i2c-algo-pca.c:182: > + int num)$ > Thanks for you comments and for sharing your knowledge ! A patch V3 will be sent, Regards, Farid, ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH V2] i2c-algo-pca: fix coding style issues in i2c-algo-pca.c [not found] ` <20100423113326.3691bdd6-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org> 2010-04-24 14:07 ` Farid Hammane @ 2010-04-26 7:41 ` Wolfram Sang 1 sibling, 0 replies; 5+ messages in thread From: Wolfram Sang @ 2010-04-26 7:41 UTC (permalink / raw) To: Jean Delvare Cc: Farid Hammane, ben-linux-elnMNo+KYs3YtjvyW6yDsg, Enrik.Berkhan-JJi787mZWgc, linux-i2c-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA [-- Attachment #1: Type: text/plain, Size: 269 bytes --] Geez, that will teach me to review whitespace-fixes while working somewhere else :( Thanks for the catch! -- Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ | [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 197 bytes --] ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-04-26 7:41 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-22 22:01 [PATCH V2] i2c-algo-pca: fix coding style issues in i2c-algo-pca.c Farid Hammane
[not found] ` <1271973715-18331-1-git-send-email-farid.hammane-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2010-04-23 0:52 ` Wolfram Sang
2010-04-23 9:33 ` Jean Delvare
[not found] ` <20100423113326.3691bdd6-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2010-04-24 14:07 ` Farid Hammane
2010-04-26 7:41 ` Wolfram Sang
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).