[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210818154935.1154-9-alistair@alistair23.me>
Date: Thu, 19 Aug 2021 01:49:32 +1000
From: Alistair Francis <alistair@...stair23.me>
To: dmitry.torokhov@...il.com, linux-input@...r.kernel.org,
linux-imx@....com, kernel@...gutronix.de, pinglinux@...il.com,
tatsunosuke.tobita@...om.com, junkpainting@...il.com,
ping.cheng@...om.com
Cc: linux-kernel@...r.kernel.org, alistair23@...il.com,
robh+dt@...nel.org, devicetree@...r.kernel.org,
Alistair Francis <alistair@...stair23.me>
Subject: [PATCH v9 08/11] 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 <alistair@...stair23.me>
---
drivers/input/touchscreen/wacom_i2c.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/drivers/input/touchscreen/wacom_i2c.c b/drivers/input/touchscreen/wacom_i2c.c
index fd486b8ef2cc..c6579a1a8d04 100644
--- a/drivers/input/touchscreen/wacom_i2c.c
+++ b/drivers/input/touchscreen/wacom_i2c.c
@@ -18,6 +18,14 @@
#include <linux/of.h>
#include <asm/unaligned.h>
+// Bitmasks (for data[3])
+#define WACOM_TIP_SWITCH_bm (1 << 0)
+#define WACOM_BARREL_SWITCH_bm (1 << 1)
+#define WACOM_ERASER_bm (1 << 2)
+#define WACOM_INVERT_bm (1 << 3)
+#define WACOM_BARREL_SWITCH_2_bm (1 << 4)
+#define WACOM_IN_RANGE_bm (1 << 5)
+
// Registers
#define WACOM_COMMAND_LSB 0x04
#define WACOM_COMMAND_MSB 0x00
@@ -148,10 +156,10 @@ static irqreturn_t wacom_i2c_irq(int irq, void *dev_id)
if (error < 0)
goto out;
- tsw = data[3] & 0x01;
- ers = data[3] & 0x04;
- f1 = data[3] & 0x02;
- f2 = data[3] & 0x10;
+ tsw = data[3] & WACOM_TIP_SWITCH_bm;
+ ers = data[3] & WACOM_ERASER_bm;
+ f1 = data[3] & WACOM_BARREL_SWITCH_bm;
+ f2 = data[3] & WACOM_BARREL_SWITCH_2_bm;
x = le16_to_cpup((__le16 *)&data[4]);
y = le16_to_cpup((__le16 *)&data[6]);
pressure = le16_to_cpup((__le16 *)&data[8]);
--
2.31.1
Powered by blists - more mailing lists