Re: [PATCH] Input: adp5589-keys - use BIT()
From: Dmitry Torokhov
Date: Thu Nov 19 2020 - 02:44:28 EST
On Wed, Nov 18, 2020 at 11:34:28PM -0800, Joe Perches wrote:
> 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;
Different "bit" tough - row vs column.
>
> > 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;
>
>
Thanks.
--
Dmitry