public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Andrew F. Davis" <afd@ti.com>
To: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Cc: Jonathan Cameron <jic23@kernel.org>, <linux-iio@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] iio: dac: mcp4725: Remove unneeded conversions to bool
Date: Fri, 1 Jul 2016 10:18:28 -0500	[thread overview]
Message-ID: <577689C4.6090803@ti.com> (raw)
In-Reply-To: <alpine.DEB.2.02.1607011700150.7271@pmeerw.net>

On 07/01/2016 10:03 AM, Peter Meerwald-Stadler wrote:
> 
>> Found with scripts/coccinelle/misc/boolconv.cocci.
> 
> I'd argue that
> 
>         pd = (inbuf[0] >> 1) & 0x3;
>         if (pd) {
>                 data->powerdown = true;
>                 data->powerdown_mode = pd - 1;
>         } else {
>                 data->powerdown = false;
>                 data->powerdown_mode = 2; /* largest register to gnd */
>         }
> 
> is less compact but probably easier to read/understand;
> 

I agree, this is a much better fix. Would you like to submit this
version as a patch?

Andrew

>> Signed-off-by: Andrew F. Davis <afd@ti.com>
> 
> but I'm fine with the proposed patch as well to make cocci happy
> 
> regards, p.
> 
>> ---
>>  drivers/iio/dac/mcp4725.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/iio/dac/mcp4725.c b/drivers/iio/dac/mcp4725.c
>> index cca935c..c3bb3fd 100644
>> --- a/drivers/iio/dac/mcp4725.c
>> +++ b/drivers/iio/dac/mcp4725.c
>> @@ -361,7 +361,7 @@ static int mcp4725_probe(struct i2c_client *client,
>>  		return err;
>>  	}
>>  	pd = (inbuf[0] >> 1) & 0x3;
>> -	data->powerdown = pd > 0 ? true : false;
>> +	data->powerdown = pd > 0;
>>  	data->powerdown_mode = pd ? pd - 1 : 2; /* largest register to gnd */
>>  	data->dac_value = (inbuf[1] << 4) | (inbuf[2] >> 4);
>>  
>>
> 

      reply	other threads:[~2016-07-01 15:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-01 14:33 [PATCH] iio: dac: mcp4725: Remove unneeded conversions to bool Andrew F. Davis
2016-07-01 15:03 ` Peter Meerwald-Stadler
2016-07-01 15:18   ` Andrew F. Davis [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=577689C4.6090803@ti.com \
    --to=afd@ti.com \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmeerw@pmeerw.net \
    /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