Re: [PATCH 25/26] Input: maplecontrol - fix style issues
Dmitry Torokhov <[email protected]> Sun, 5 Jul 2026 13:26:36 -0700
| Newsgroups | org.kernel.vger.linux-sh,org.infradead.lists.linux-mtd,org.kernel.vger.linux-input,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
On Sun, Jul 05, 2026 at 08:28:39PM +0100, Adrian McMenamin wrote: > On Sat, 4 Jul 2026 at 06:58, Dmitry Torokhov <[email protected]> wrote: > > > > Fix coding style and formatting issues reported by checkpatch.pl and > > switch to using BIT(). When reporting D-PAD events avoid conditionals. > > > > Assisted-by: Antigravity:gemini-3.5-flash > > Signed-off-by: Dmitry Torokhov <[email protected]> > > --- > > drivers/input/joystick/maplecontrol.c | 25 ++++++++++++------------- > > 1 file changed, 12 insertions(+), 13 deletions(-) > > > > diff --git a/drivers/input/joystick/maplecontrol.c b/drivers/input/joystick/maplecontrol.c > > index 3ef6652d40cb..457a73d91239 100644 > > --- a/drivers/input/joystick/maplecontrol.c > > +++ b/drivers/input/joystick/maplecontrol.c > > @@ -35,22 +35,22 @@ static void dc_pad_callback(struct mapleq *mq) > > buttons = ~le16_to_cpup((__le16 *)(res + 8)); > > > > input_report_abs(dev, ABS_HAT0Y, > > - (buttons & 0x0010 ? -1 : 0) + (buttons & 0x0020 ? 1 : 0)); > > + !!(buttons & BIT(5)) - !!(buttons & BIT(4))); > > input_report_abs(dev, ABS_HAT0X, > > - (buttons & 0x0040 ? -1 : 0) + (buttons & 0x0080 ? 1 : 0)); > > + !!(buttons & BIT(7)) - !!(buttons & BIT(6))); > > > Maybe I have missed something but what is this !! operator? Double negation to coerce the value to [0, 1] range avoiding conditional/branching? -- Dmitry