Skip to content

Commit

Permalink
Input: synaptics - do not mix logical and bitwise operations
Browse files Browse the repository at this point in the history
Let's stop using !!x to reduce value of trackstick button expression to 0/1
and use shift instead. This removes the following sparse warning:

  CHECK   drivers/input/mouse/synaptics.c
drivers/input/mouse/synaptics.c:943:79: warning: dubious: !x | y

Also, the bits we are testing are not capabilities, so lets drop "_CAP"
suffix from macro names.

Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
  • Loading branch information
Dmitry Torokhov committed Mar 23, 2017
1 parent cf5cd9d commit 996b9ee
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions drivers/input/mouse/synaptics.c
Original file line number Diff line number Diff line change
Expand Up @@ -884,9 +884,9 @@ static void synaptics_report_ext_buttons(struct psmouse *psmouse,
u8 pt_buttons;

/* The trackstick expects at most 3 buttons */
pt_buttons = SYN_CAP_EXT_BUTTON_STICK_L(hw->ext_buttons) |
SYN_CAP_EXT_BUTTON_STICK_R(hw->ext_buttons) << 1 |
SYN_CAP_EXT_BUTTON_STICK_M(hw->ext_buttons) << 2;
pt_buttons = SYN_EXT_BUTTON_STICK_L(hw->ext_buttons) |
SYN_EXT_BUTTON_STICK_R(hw->ext_buttons) << 1 |
SYN_EXT_BUTTON_STICK_M(hw->ext_buttons) << 2;

serio_interrupt(priv->pt_port,
PSMOUSE_OOB_EXTRA_BTNS, SERIO_OOB_DATA);
Expand Down
6 changes: 3 additions & 3 deletions drivers/input/mouse/synaptics.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@
#define SYN_CAP_EXT_BUTTONS_STICK(ex10) ((ex10) & 0x010000)
#define SYN_CAP_SECUREPAD(ex10) ((ex10) & 0x020000)

#define SYN_CAP_EXT_BUTTON_STICK_L(eb) (!!((eb) & 0x01))
#define SYN_CAP_EXT_BUTTON_STICK_M(eb) (!!((eb) & 0x02))
#define SYN_CAP_EXT_BUTTON_STICK_R(eb) (!!((eb) & 0x04))
#define SYN_EXT_BUTTON_STICK_L(eb) (((eb) & BIT(0)) >> 0)
#define SYN_EXT_BUTTON_STICK_M(eb) (((eb) & BIT(1)) >> 1)
#define SYN_EXT_BUTTON_STICK_R(eb) (((eb) & BIT(2)) >> 2)

/* synaptics modes query bits */
#define SYN_MODE_ABSOLUTE(m) ((m) & (1 << 7))
Expand Down

0 comments on commit 996b9ee

Please sign in to comment.