Skip to content

Commit 91e2e76

Browse files
alistair23dtor
authored andcommitted
Input: wacom_i2c - use macros for the bit masks
To make the code easier to read use macros for the bit masks. Signed-off-by: Alistair Francis <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent 27931d3 commit 91e2e76

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

drivers/input/touchscreen/wacom_i2c.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
77
*/
88

9+
#include <linux/bits.h>
910
#include <linux/module.h>
1011
#include <linux/input.h>
1112
#include <linux/i2c.h>
@@ -14,6 +15,15 @@
1415
#include <linux/interrupt.h>
1516
#include <asm/unaligned.h>
1617

18+
/* Bitmasks (for data[3]) */
19+
#define WACOM_TIP_SWITCH BIT(0)
20+
#define WACOM_BARREL_SWITCH BIT(1)
21+
#define WACOM_ERASER BIT(2)
22+
#define WACOM_INVERT BIT(3)
23+
#define WACOM_BARREL_SWITCH_2 BIT(4)
24+
#define WACOM_IN_PROXIMITY BIT(5)
25+
26+
/* Registers */
1727
#define WACOM_CMD_QUERY0 0x04
1828
#define WACOM_CMD_QUERY1 0x00
1929
#define WACOM_CMD_QUERY2 0x33
@@ -99,19 +109,19 @@ static irqreturn_t wacom_i2c_irq(int irq, void *dev_id)
99109
if (error < 0)
100110
goto out;
101111

102-
tsw = data[3] & 0x01;
103-
ers = data[3] & 0x04;
104-
f1 = data[3] & 0x02;
105-
f2 = data[3] & 0x10;
112+
tsw = data[3] & WACOM_TIP_SWITCH;
113+
ers = data[3] & WACOM_ERASER;
114+
f1 = data[3] & WACOM_BARREL_SWITCH;
115+
f2 = data[3] & WACOM_BARREL_SWITCH_2;
106116
x = le16_to_cpup((__le16 *)&data[4]);
107117
y = le16_to_cpup((__le16 *)&data[6]);
108118
pressure = le16_to_cpup((__le16 *)&data[8]);
109119

110120
if (!wac_i2c->prox)
111-
wac_i2c->tool = (data[3] & 0x0c) ?
121+
wac_i2c->tool = (data[3] & (WACOM_ERASER | WACOM_INVERT)) ?
112122
BTN_TOOL_RUBBER : BTN_TOOL_PEN;
113123

114-
wac_i2c->prox = data[3] & 0x20;
124+
wac_i2c->prox = data[3] & WACOM_IN_PROXIMITY;
115125

116126
input_report_key(input, BTN_TOUCH, tsw || ers);
117127
input_report_key(input, wac_i2c->tool, wac_i2c->prox);

0 commit comments

Comments
 (0)