linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
To: Wolfram Sang <w.sang-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Paul Mundt <lethal-M7jkjyW5wf5g9hUCZPvPmw@public.gmane.org>,
	Ben Dooks <ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org>
Subject: Re: [PATCH] i2c/highlander: remover superflous variable
Date: Tue, 2 Feb 2010 13:29:40 +0100	[thread overview]
Message-ID: <20100202132940.3692a29f@hyperion.delvare> (raw)
In-Reply-To: <1265113063-22894-1-git-send-email-w.sang-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>

On Tue,  2 Feb 2010 13:17:43 +0100, Wolfram Sang wrote:
> When cppcheck found this flaw
> 
> [./i2c/busses/i2c-highlander.c:284]: (style) Warning - using char variable in bit operation
> 
> it was noted that the 'read'-variable could just be removed as read_write can
> only be 0 or 1 anyhow. So, we remove the flaw by simplifying the code.
> 
> Reported-by: d binderman <dcb314-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org>
> Signed-off-by: Wolfram Sang <w.sang-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
> Cc: Paul Mundt <lethal-M7jkjyW5wf5g9hUCZPvPmw@public.gmane.org>
> Cc: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
> Cc: Ben Dooks <ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org>
> ---
> 
> There was no patch following the original report, so I picked it up. Not
> tested, due to no hardware.
> 
> Jean, I put you on CC as you commented on the original mail, although it is
> more an embedded driver.
> 
>  drivers/i2c/busses/i2c-highlander.c |    5 ++---
>  1 files changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-highlander.c b/drivers/i2c/busses/i2c-highlander.c
> index 87ecace..db290b9 100644
> --- a/drivers/i2c/busses/i2c-highlander.c
> +++ b/drivers/i2c/busses/i2c-highlander.c
> @@ -281,7 +281,6 @@ static int highlander_i2c_smbus_xfer(struct i2c_adapter *adap, u16 addr,
>  				  union i2c_smbus_data *data)
>  {
>  	struct highlander_i2c_dev *dev = i2c_get_adapdata(adap);
> -	int read = read_write & I2C_SMBUS_READ;
>  	u16 tmp;
>  
>  	init_completion(&dev->cmd_complete);
> @@ -336,11 +335,11 @@ static int highlander_i2c_smbus_xfer(struct i2c_adapter *adap, u16 addr,
>  	highlander_i2c_done(dev);
>  
>  	/* Set slave address */
> -	iowrite16((addr << 1) | read, dev->base + SMSMADR);
> +	iowrite16((addr << 1) | read_write, dev->base + SMSMADR);
>  
>  	highlander_i2c_command(dev, command, dev->buf_len);
>  
> -	if (read)
> +	if (read_write)
>  		return highlander_i2c_read(dev);
>  	else
>  		return highlander_i2c_write(dev);

Acked-by: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>

Thanks Wolfram.

-- 
Jean Delvare

  parent reply	other threads:[~2010-02-02 12:29 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-01  9:51 i2c/busses/i2c-highlander.c: using char variable in bit operation d binderman
     [not found] ` <BLU108-W10538CE8A7EF6373FB36AE9C580-MsuGFMq8XAE@public.gmane.org>
2010-02-01 10:07   ` Jean Delvare
     [not found]     ` <20100201110721.461fd142-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2010-02-01 10:15       ` Wolfram Sang
     [not found]         ` <20100201101509.GB3288-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2010-02-02 12:17           ` [PATCH] i2c/highlander: remover superflous variable Wolfram Sang
     [not found]             ` <1265113063-22894-1-git-send-email-w.sang-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2010-02-02 12:29               ` Jean Delvare [this message]
2010-02-02 14:31               ` Paul Mundt

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=20100202132940.3692a29f@hyperion.delvare \
    --to=khali-puyad+kwke1g9huczpvpmw@public.gmane.org \
    --cc=ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org \
    --cc=lethal-M7jkjyW5wf5g9hUCZPvPmw@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=w.sang-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org \
    /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;
as well as URLs for NNTP newsgroup(s).