Re: [PATCH] Input: adp5589-keys - use BIT()

From: Joe Perches
Date: Thu Nov 19 2020 - 02:34:32 EST


On Wed, 2020-11-18 at 23:24 -0800, Dmitry Torokhov wrote:
> Let's use BIT() macro instead of explicitly shifting '1'.
[]
> diff --git a/drivers/input/keyboard/adp5589-keys.c b/drivers/input/keyboard/adp5589-keys.c

> @@ -651,13 +652,13 @@ static int adp5589_setup(struct adp5589_kpad *kpad)
>   unsigned short pin = pdata->gpimap[i].pin;
>  

trivia:

Perhaps nicer to create and use a temporary

unsigned int bit = BIT(pin - kpad->var->gpi_pin_col_base);

so in these places below:

>   if (pin <= kpad->var->gpi_pin_row_end) {
> - evt_mode1 |= (1 << (pin - kpad->var->gpi_pin_row_base));
> + evt_mode1 |= BIT(pin - kpad->var->gpi_pin_row_base);

evt_mode1 |= bit;

>   } else {
>   evt_mode2 |=
> - ((1 << (pin - kpad->var->gpi_pin_col_base)) & 0xFF);
> + BIT(pin - kpad->var->gpi_pin_col_base) & 0xFF;

evt_mode2 |= bit & 0xff;

>   if (!kpad->is_adp5585)
> - evt_mode3 |= ((1 << (pin -
> - kpad->var->gpi_pin_col_base)) >> 8);
> + evt_mode3 |=
> + BIT(pin - kpad->var->gpi_pin_col_base) >> 8;

evt_mode3 |= bit >> 8;