Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Duje Mihanović and committed by
Dmitry Torokhov
c0ca3dbd a4735d40

+7 -11
+7 -11
drivers/input/touchscreen/imagis.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0-only 2 2 3 + #include <linux/bitfield.h> 3 4 #include <linux/bits.h> 4 5 #include <linux/delay.h> 5 6 #include <linux/i2c.h> ··· 30 29 #define IST3038C_I2C_RETRY_COUNT 3 31 30 #define IST3038C_MAX_FINGER_NUM 10 32 31 #define IST3038C_X_MASK GENMASK(23, 12) 33 - #define IST3038C_X_SHIFT 12 34 32 #define IST3038C_Y_MASK GENMASK(11, 0) 35 33 #define IST3038C_AREA_MASK GENMASK(27, 24) 36 - #define IST3038C_AREA_SHIFT 24 37 34 #define IST3038C_FINGER_COUNT_MASK GENMASK(15, 12) 38 - #define IST3038C_FINGER_COUNT_SHIFT 12 39 35 #define IST3038C_FINGER_STATUS_MASK GENMASK(9, 0) 40 36 41 37 struct imagis_properties { ··· 104 106 goto out; 105 107 } 106 108 107 - finger_count = (intr_message & IST3038C_FINGER_COUNT_MASK) >> 108 - IST3038C_FINGER_COUNT_SHIFT; 109 + finger_count = FIELD_GET(IST3038C_FINGER_COUNT_MASK, intr_message); 109 110 if (finger_count > IST3038C_MAX_FINGER_NUM) { 110 111 dev_err(&ts->client->dev, 111 112 "finger count %d is more than maximum supported\n", ··· 112 115 goto out; 113 116 } 114 117 115 - finger_pressed = intr_message & IST3038C_FINGER_STATUS_MASK; 118 + finger_pressed = FIELD_GET(IST3038C_FINGER_STATUS_MASK, intr_message); 116 119 117 120 for (i = 0; i < finger_count; i++) { 118 121 if (ts->tdata->protocol_b) ··· 133 136 input_mt_report_slot_state(ts->input_dev, MT_TOOL_FINGER, 134 137 finger_pressed & BIT(i)); 135 138 touchscreen_report_pos(ts->input_dev, &ts->prop, 136 - (finger_status & IST3038C_X_MASK) >> 137 - IST3038C_X_SHIFT, 138 - finger_status & IST3038C_Y_MASK, 1); 139 + FIELD_GET(IST3038C_X_MASK, finger_status), 140 + FIELD_GET(IST3038C_Y_MASK, finger_status), 141 + true); 139 142 input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, 140 - (finger_status & IST3038C_AREA_MASK) >> 141 - IST3038C_AREA_SHIFT); 143 + FIELD_GET(IST3038C_AREA_MASK, finger_status)); 142 144 } 143 145 144 146 input_mt_sync_frame(ts->input_dev);