All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Zapolskiy <vz@mleia.com>
To: Mark Brown <broonie@kernel.org>
Cc: Liam Girdwood <lgirdwood@gmail.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Alexandre Courbot <acourbot@nvidia.com>,
	Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.de>,
	linux-gpio@vger.kernel.org, alsa-devel@alsa-project.org,
	Charles Keepax <ckeepax@opensource.wolfsonmicro.com>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Axel Lin <axel.lin@ingics.com>,
	patches@opensource.wolfsonmicro.com
Subject: Re: [PATCH 5/7] ASoC: wm5100: remove bitwise operations involving GPIO level value
Date: Tue, 02 Jun 2015 23:58:25 +0300	[thread overview]
Message-ID: <556E18F1.7030008@mleia.com> (raw)
In-Reply-To: <20150602203631.GV14071@sirena.org.uk>

Hello Mark,

On 02.06.2015 23:36, Mark Brown wrote:
> On Tue, Jun 02, 2015 at 11:23:41PM +0300, Vladimir Zapolskiy wrote:
>> On 02.06.2015 22:45, Mark Brown wrote:
>>> On Tue, Jun 02, 2015 at 02:09:16AM +0300, Vladimir Zapolskiy wrote:
> 
>>>> +	unsigned int val = 0;
>>>> +
>>>> +	if (value)
>>>> +		val = 0x1 << WM5100_GP1_LVL_SHIFT;
> 
>>> Write this as an if/else so the reader doesn't have to wonder why you've
>>> missed the handling of the false case.  
> 
>> the only objection I have is that the resulting code will be two lines
>> longer. If you think this code is not clear enough (is "val" vs. "value"
>> misleading?), I'll change the rest of my patches, which contain the same
>> logic structure, please let me know.
> 
> Especially after the unrelated style change thing earlier on (which
> meant I was reading things more carefully than usual) it'd be good to
> make things as clear as possible - you're right that the val vs value
> thing isn't helping either.  

got your concern, will send an update.

> Like I say I am a bit surprised that the int/bool conversion doesn't do
> the right thing without any code changes other than the type of the
> parameter but ICBW, I didn't actually check.
> 

My tested compilers do the work right, but I can not be sure about the
whole variety of compilers, well, probably I should just follow the
standard, which in turn is expected to be quite volatile in future
revisions regarding usage of "_Bool" or future "bool" type.

If we assume the preferred Linux kernel style to use true/false
constants for boolean variables only (see the reference to
bool{init,return}.cocci), then even if bitwise and arithmetic operations
on bool type are understandable to a compiler, but probably "false <<
true" (or whatever is hidden under a variable name) is not quite
aesthetic for a human eye. This is not a technical argument though, and
I'm not sure if any clear code style policy related to the case is agreed.

--
With best wishes,
Vladimir

  reply	other threads:[~2015-06-02 20:58 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-01 23:07 [PATCH 0/7] ASoC: remove bitwise operations on GPIO level value Vladimir Zapolskiy
2015-06-01 23:09 ` [PATCH 1/7] ASoC: rt5677: add GPIO helper macros Vladimir Zapolskiy
2015-06-02  5:23   ` Takashi Iwai
2015-06-01 23:09 ` [PATCH 2/7] ASoC: rt5677: clean up gpiolib callbacks Vladimir Zapolskiy
2015-06-02 19:38   ` Mark Brown
2015-06-02 20:39     ` Vladimir Zapolskiy
2015-06-02 20:50       ` Mark Brown
2015-06-02 21:54         ` Vladimir Zapolskiy
2015-06-03 11:38           ` Mark Brown
2015-06-01 23:09 ` [PATCH 3/7] ASoC: wm8903: generalize GPIO control register bits Vladimir Zapolskiy
2015-06-02  9:19   ` Charles Keepax
2015-06-04  8:30   ` Linus Walleij
2015-06-04  8:47     ` [alsa-devel] " Charles Keepax
2015-06-04  9:19     ` Mark Brown
2015-06-04  9:24       ` Charles Keepax
2015-06-04 10:34         ` Mark Brown
2015-06-01 23:09 ` [PATCH 4/7] ASoC: wm8903: simplify gpiolib callbacks Vladimir Zapolskiy
2015-06-02  8:38   ` Charles Keepax
2015-06-02 19:41   ` Mark Brown
2015-06-02 20:18     ` Vladimir Zapolskiy
2015-06-02 20:31       ` Mark Brown
2015-06-02 20:41         ` Vladimir Zapolskiy
2015-06-01 23:09 ` [PATCH 5/7] ASoC: wm5100: remove bitwise operations involving GPIO level value Vladimir Zapolskiy
2015-06-02  8:40   ` Charles Keepax
2015-06-02 19:45   ` Mark Brown
2015-06-02 20:23     ` Vladimir Zapolskiy
2015-06-02 20:36       ` Mark Brown
2015-06-02 20:58         ` Vladimir Zapolskiy [this message]
2015-06-03 10:50       ` Trent Piepho
2015-06-03 11:07         ` Mark Brown
2015-06-03 19:13         ` [alsa-devel] " Vladimir Zapolskiy
2015-06-03 21:51           ` Trent Piepho
2015-06-03 22:58             ` Vladimir Zapolskiy
2015-06-01 23:09 ` [PATCH 6/7] ASoC: wm8962: " Vladimir Zapolskiy
2015-06-02  8:41   ` Charles Keepax
2015-06-01 23:09 ` [PATCH 7/7] ASoC: wm8996: " Vladimir Zapolskiy
2015-06-02  8:43   ` Charles Keepax

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=556E18F1.7030008@mleia.com \
    --to=vz@mleia.com \
    --cc=acourbot@nvidia.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=axel.lin@ingics.com \
    --cc=broonie@kernel.org \
    --cc=ckeepax@opensource.wolfsonmicro.com \
    --cc=lars@metafoo.de \
    --cc=lgirdwood@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=patches@opensource.wolfsonmicro.com \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.