]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-6.1/input-imagis-use-field_get-where-applicable.patch
Fixes for 6.1
[thirdparty/kernel/stable-queue.git] / queue-6.1 / input-imagis-use-field_get-where-applicable.patch
1 From f8b816e540c450d74160f977458497918f470f29 Mon Sep 17 00:00:00 2001
2 From: Sasha Levin <sashal@kernel.org>
3 Date: Sat, 9 Mar 2024 21:18:05 -0800
4 Subject: Input: imagis - use FIELD_GET where applicable
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 From: Duje Mihanović <duje.mihanovic@skole.hr>
10
11 [ Upstream commit c0ca3dbd03d66c6b9e044f48720e6ab5cef37ae5 ]
12
13 Instead of manually extracting certain bits from registers with binary
14 ANDs and shifts, the FIELD_GET macro can be used. With this in mind, the
15 *_SHIFT macros can be dropped.
16
17 Signed-off-by: Duje Mihanović <duje.mihanovic@skole.hr>
18 Link: https://lore.kernel.org/r/20240306-b4-imagis-keys-v3-1-2c429afa8420@skole.hr
19 Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
20 Signed-off-by: Sasha Levin <sashal@kernel.org>
21 ---
22 drivers/input/touchscreen/imagis.c | 18 +++++++-----------
23 1 file changed, 7 insertions(+), 11 deletions(-)
24
25 diff --git a/drivers/input/touchscreen/imagis.c b/drivers/input/touchscreen/imagis.c
26 index b667914a44f1d..2636e1c9435d8 100644
27 --- a/drivers/input/touchscreen/imagis.c
28 +++ b/drivers/input/touchscreen/imagis.c
29 @@ -1,5 +1,6 @@
30 // SPDX-License-Identifier: GPL-2.0-only
31
32 +#include <linux/bitfield.h>
33 #include <linux/bits.h>
34 #include <linux/delay.h>
35 #include <linux/i2c.h>
36 @@ -23,12 +24,9 @@
37 #define IST3038C_I2C_RETRY_COUNT 3
38 #define IST3038C_MAX_FINGER_NUM 10
39 #define IST3038C_X_MASK GENMASK(23, 12)
40 -#define IST3038C_X_SHIFT 12
41 #define IST3038C_Y_MASK GENMASK(11, 0)
42 #define IST3038C_AREA_MASK GENMASK(27, 24)
43 -#define IST3038C_AREA_SHIFT 24
44 #define IST3038C_FINGER_COUNT_MASK GENMASK(15, 12)
45 -#define IST3038C_FINGER_COUNT_SHIFT 12
46 #define IST3038C_FINGER_STATUS_MASK GENMASK(9, 0)
47
48 struct imagis_ts {
49 @@ -92,8 +90,7 @@ static irqreturn_t imagis_interrupt(int irq, void *dev_id)
50 goto out;
51 }
52
53 - finger_count = (intr_message & IST3038C_FINGER_COUNT_MASK) >>
54 - IST3038C_FINGER_COUNT_SHIFT;
55 + finger_count = FIELD_GET(IST3038C_FINGER_COUNT_MASK, intr_message);
56 if (finger_count > IST3038C_MAX_FINGER_NUM) {
57 dev_err(&ts->client->dev,
58 "finger count %d is more than maximum supported\n",
59 @@ -101,7 +98,7 @@ static irqreturn_t imagis_interrupt(int irq, void *dev_id)
60 goto out;
61 }
62
63 - finger_pressed = intr_message & IST3038C_FINGER_STATUS_MASK;
64 + finger_pressed = FIELD_GET(IST3038C_FINGER_STATUS_MASK, intr_message);
65
66 for (i = 0; i < finger_count; i++) {
67 error = imagis_i2c_read_reg(ts,
68 @@ -118,12 +115,11 @@ static irqreturn_t imagis_interrupt(int irq, void *dev_id)
69 input_mt_report_slot_state(ts->input_dev, MT_TOOL_FINGER,
70 finger_pressed & BIT(i));
71 touchscreen_report_pos(ts->input_dev, &ts->prop,
72 - (finger_status & IST3038C_X_MASK) >>
73 - IST3038C_X_SHIFT,
74 - finger_status & IST3038C_Y_MASK, 1);
75 + FIELD_GET(IST3038C_X_MASK, finger_status),
76 + FIELD_GET(IST3038C_Y_MASK, finger_status),
77 + true);
78 input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR,
79 - (finger_status & IST3038C_AREA_MASK) >>
80 - IST3038C_AREA_SHIFT);
81 + FIELD_GET(IST3038C_AREA_MASK, finger_status));
82 }
83
84 input_mt_sync_frame(ts->input_dev);
85 --
86 2.43.0
87