public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Wolfram Sang <wsa@the-dreams.de>
Cc: RAGHAVENDRA GANIGA <ravi23ganiga@gmail.com>,
	linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] i2c: i2c-core: fix coding style issues in i2c-core.c
Date: Tue, 14 Jan 2014 11:06:37 -0800	[thread overview]
Message-ID: <1389726397.24849.47.camel@joe-AO722> (raw)
In-Reply-To: <20140114183845.GD10340@katana>

On Tue, 2014-01-14 at 19:38 +0100, Wolfram Sang wrote:
> > --- a/drivers/i2c/i2c-core.c
> > +++ b/drivers/i2c/i2c-core.c
> > @@ -1737,9 +1737,9 @@ int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
> >  		for (ret = 0; ret < num; ret++) {
> >  			dev_dbg(&adap->dev, "master_xfer[%d] %c, addr=0x%02x, len=%d%s\n",
> >  				ret,
> > -				((msgs[ret].flags & I2C_M_RD) ? 'R' : 'W'),
> > +				msgs[ret].flags & I2C_M_RD ? 'R' : 'W',
> >  				msgs[ret].addr, msgs[ret].len,
> > -				(msgs[ret].flags & I2C_M_RECV_LEN) ? "+" : "");
> > +				msgs[ret].flags & I2C_M_RECV_LEN ? "+" : "");
> 
> Don't spend time changing too much here like the paranthesis. It will
> probably be removed soon in favour of the tracing approach.

That'd be good.  There are a lot of function tracing style
dev_dbg uses in i2c-core that can be removed.

Just an fyi not to Raghavendra:

This sort of loop could have been further modified removing
the unnecessary #if DEBUG/#endif too

Also, reusing ret for a loop index is efficient, but a bit odd.

Maybe something like:

diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index d74c0b3..5ca078e 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -1758,14 +1758,13 @@ int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
 	 */
 
 	if (adap->algo->master_xfer) {
-#ifdef DEBUG
-		for (ret = 0; ret < num; ret++) {
-			dev_dbg(&adap->dev, "master_xfer[%d] %c, addr=0x%02x, "
-				"len=%d%s\n", ret, (msgs[ret].flags & I2C_M_RD)
-				? 'R' : 'W', msgs[ret].addr, msgs[ret].len,
-				(msgs[ret].flags & I2C_M_RECV_LEN) ? "+" : "");
-		}
-#endif
+		int i;
+
+		for (i = 0; i < num; i++)
+			dev_dbg(&adap->dev, "master_xfer[%d] %c, addr=0x%02x, len=%d%s\n",
+				ret, msgs[i].flags & I2C_M_RD ? 'R' : 'W',
+				msgs[i].addr, msgs[i].len,
+				msgs[i].flags & I2C_M_RECV_LEN ? "+" : "");
 
 		if (in_atomic() || irqs_disabled()) {
 			ret = i2c_trylock_adapter(adap);

      reply	other threads:[~2014-01-14 19:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-14 15:25 [PATCH 3/3] i2c: i2c-core: fix coding style issues in i2c-core.c RAGHAVENDRA GANIGA
     [not found] ` <525C0CDB.6020305-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-01-14 18:38   ` Wolfram Sang
2014-01-14 19:06     ` Joe Perches [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1389726397.24849.47.camel@joe-AO722 \
    --to=joe@perches.com \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ravi23ganiga@gmail.com \
    --cc=wsa@the-dreams.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox