Re: [PATCH] gpio: tc3589x: use BIT() macro

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
> ---
>  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@xxxxxxxxxx>

Regards,
Bjorn
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux