lkml.org 
[lkml]   [2020]   [Nov]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] Input: adp5589-keys - use BIT()
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

\
 
 \ /
  Last update: 2020-11-19 08:45    [W:2.059 / U:0.000 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site