Skip to content

Commit c0ca3db

Browse files
LegoLivesMatterdtor
authored andcommitted
Input: imagis - use FIELD_GET where applicable
Instead of manually extracting certain bits from registers with binary ANDs and shifts, the FIELD_GET macro can be used. With this in mind, the *_SHIFT macros can be dropped. Signed-off-by: Duje Mihanović <duje.mihanovic@skole.hr> Link: https://lore.kernel.org/r/20240306-b4-imagis-keys-v3-1-2c429afa8420@skole.hr Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
1 parent a4735d4 commit c0ca3db

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

drivers/input/touchscreen/imagis.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0-only
22

3+
#include <linux/bitfield.h>
34
#include <linux/bits.h>
45
#include <linux/delay.h>
56
#include <linux/i2c.h>
@@ -29,12 +30,9 @@
2930
#define IST3038C_I2C_RETRY_COUNT 3
3031
#define IST3038C_MAX_FINGER_NUM 10
3132
#define IST3038C_X_MASK GENMASK(23, 12)
32-
#define IST3038C_X_SHIFT 12
3333
#define IST3038C_Y_MASK GENMASK(11, 0)
3434
#define IST3038C_AREA_MASK GENMASK(27, 24)
35-
#define IST3038C_AREA_SHIFT 24
3635
#define IST3038C_FINGER_COUNT_MASK GENMASK(15, 12)
37-
#define IST3038C_FINGER_COUNT_SHIFT 12
3836
#define IST3038C_FINGER_STATUS_MASK GENMASK(9, 0)
3937

4038
struct imagis_properties {
@@ -106,16 +104,15 @@ static irqreturn_t imagis_interrupt(int irq, void *dev_id)
106104
goto out;
107105
}
108106

109-
finger_count = (intr_message & IST3038C_FINGER_COUNT_MASK) >>
110-
IST3038C_FINGER_COUNT_SHIFT;
107+
finger_count = FIELD_GET(IST3038C_FINGER_COUNT_MASK, intr_message);
111108
if (finger_count > IST3038C_MAX_FINGER_NUM) {
112109
dev_err(&ts->client->dev,
113110
"finger count %d is more than maximum supported\n",
114111
finger_count);
115112
goto out;
116113
}
117114

118-
finger_pressed = intr_message & IST3038C_FINGER_STATUS_MASK;
115+
finger_pressed = FIELD_GET(IST3038C_FINGER_STATUS_MASK, intr_message);
119116

120117
for (i = 0; i < finger_count; i++) {
121118
if (ts->tdata->protocol_b)
@@ -136,12 +133,11 @@ static irqreturn_t imagis_interrupt(int irq, void *dev_id)
136133
input_mt_report_slot_state(ts->input_dev, MT_TOOL_FINGER,
137134
finger_pressed & BIT(i));
138135
touchscreen_report_pos(ts->input_dev, &ts->prop,
139-
(finger_status & IST3038C_X_MASK) >>
140-
IST3038C_X_SHIFT,
141-
finger_status & IST3038C_Y_MASK, 1);
136+
FIELD_GET(IST3038C_X_MASK, finger_status),
137+
FIELD_GET(IST3038C_Y_MASK, finger_status),
138+
true);
142139
input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR,
143-
(finger_status & IST3038C_AREA_MASK) >>
144-
IST3038C_AREA_SHIFT);
140+
FIELD_GET(IST3038C_AREA_MASK, finger_status));
145141
}
146142

147143
input_mt_sync_frame(ts->input_dev);

0 commit comments

Comments
 (0)