linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bjorn Andersson <bjorn.andersson@linaro.org>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: linux-gpio@vger.kernel.org, Alexandre Courbot <acourbot@nvidia.com>
Subject: Re: [PATCH] gpio: tc3589x: use BIT() macro
Date: Tue, 5 Apr 2016 06:52:33 -0700	[thread overview]
Message-ID: <20160405135233.GE391@tuxbot> (raw)
In-Reply-To: <1459861855-1975-1-git-send-email-linus.walleij@linaro.org>

On Tue 05 Apr 06:10 PDT 2016, Linus Walleij wrote:

> This switch to use BIT(n) instead of (1 << n) which is less
> to the point. Most GPIO drivers do this to avoid mistakes.
> Also switch from using <linux/gpio.h> to the apropriate
> <linux/gpio/driver.h> include.
> 
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
>  drivers/gpio/gpio-tc3589x.c | 15 ++++++++-------
>  1 file changed, 8 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/gpio/gpio-tc3589x.c b/drivers/gpio/gpio-tc3589x.c
[..]
> @@ -55,7 +56,7 @@ static void tc3589x_gpio_set(struct gpio_chip *chip, unsigned offset, int val)
>  	struct tc3589x *tc3589x = tc3589x_gpio->tc3589x;
>  	u8 reg = TC3589x_GPIODATA0 + (offset / 8) * 2;
>  	unsigned pos = offset % 8;
> -	u8 data[] = {!!val << pos, 1 << pos};
> +	u8 data[] = {!!val << pos, BIT(pos)};
                        ^
                        |
The first part of this is also a bitmask, so even though this is
slightly messier I think for consistency you should go with:

u8 data[] = {val ? BIT(pos) : 0, BIT(pos)};

>  
>  	tc3589x_block_write(tc3589x, reg, ARRAY_SIZE(data), data);
>  }

The rest looks good,

Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>

Regards,
Bjorn

  reply	other threads:[~2016-04-05 13:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-05 13:10 [PATCH] gpio: tc3589x: use BIT() macro Linus Walleij
2016-04-05 13:52 ` Bjorn Andersson [this message]
2016-04-05 14:59   ` Linus Walleij

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=20160405135233.GE391@tuxbot \
    --to=bjorn.andersson@linaro.org \
    --cc=acourbot@nvidia.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.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).