mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-28 21:33:52 +00:00
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>
This commit is contained in:
parent
a4735d40a5
commit
c0ca3dbd03
1 changed files with 7 additions and 11 deletions
|
@ -1,5 +1,6 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0-only
|
// SPDX-License-Identifier: GPL-2.0-only
|
||||||
|
|
||||||
|
#include <linux/bitfield.h>
|
||||||
#include <linux/bits.h>
|
#include <linux/bits.h>
|
||||||
#include <linux/delay.h>
|
#include <linux/delay.h>
|
||||||
#include <linux/i2c.h>
|
#include <linux/i2c.h>
|
||||||
|
@ -29,12 +30,9 @@
|
||||||
#define IST3038C_I2C_RETRY_COUNT 3
|
#define IST3038C_I2C_RETRY_COUNT 3
|
||||||
#define IST3038C_MAX_FINGER_NUM 10
|
#define IST3038C_MAX_FINGER_NUM 10
|
||||||
#define IST3038C_X_MASK GENMASK(23, 12)
|
#define IST3038C_X_MASK GENMASK(23, 12)
|
||||||
#define IST3038C_X_SHIFT 12
|
|
||||||
#define IST3038C_Y_MASK GENMASK(11, 0)
|
#define IST3038C_Y_MASK GENMASK(11, 0)
|
||||||
#define IST3038C_AREA_MASK GENMASK(27, 24)
|
#define IST3038C_AREA_MASK GENMASK(27, 24)
|
||||||
#define IST3038C_AREA_SHIFT 24
|
|
||||||
#define IST3038C_FINGER_COUNT_MASK GENMASK(15, 12)
|
#define IST3038C_FINGER_COUNT_MASK GENMASK(15, 12)
|
||||||
#define IST3038C_FINGER_COUNT_SHIFT 12
|
|
||||||
#define IST3038C_FINGER_STATUS_MASK GENMASK(9, 0)
|
#define IST3038C_FINGER_STATUS_MASK GENMASK(9, 0)
|
||||||
|
|
||||||
struct imagis_properties {
|
struct imagis_properties {
|
||||||
|
@ -106,8 +104,7 @@ static irqreturn_t imagis_interrupt(int irq, void *dev_id)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
finger_count = (intr_message & IST3038C_FINGER_COUNT_MASK) >>
|
finger_count = FIELD_GET(IST3038C_FINGER_COUNT_MASK, intr_message);
|
||||||
IST3038C_FINGER_COUNT_SHIFT;
|
|
||||||
if (finger_count > IST3038C_MAX_FINGER_NUM) {
|
if (finger_count > IST3038C_MAX_FINGER_NUM) {
|
||||||
dev_err(&ts->client->dev,
|
dev_err(&ts->client->dev,
|
||||||
"finger count %d is more than maximum supported\n",
|
"finger count %d is more than maximum supported\n",
|
||||||
|
@ -115,7 +112,7 @@ static irqreturn_t imagis_interrupt(int irq, void *dev_id)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
finger_pressed = intr_message & IST3038C_FINGER_STATUS_MASK;
|
finger_pressed = FIELD_GET(IST3038C_FINGER_STATUS_MASK, intr_message);
|
||||||
|
|
||||||
for (i = 0; i < finger_count; i++) {
|
for (i = 0; i < finger_count; i++) {
|
||||||
if (ts->tdata->protocol_b)
|
if (ts->tdata->protocol_b)
|
||||||
|
@ -136,12 +133,11 @@ static irqreturn_t imagis_interrupt(int irq, void *dev_id)
|
||||||
input_mt_report_slot_state(ts->input_dev, MT_TOOL_FINGER,
|
input_mt_report_slot_state(ts->input_dev, MT_TOOL_FINGER,
|
||||||
finger_pressed & BIT(i));
|
finger_pressed & BIT(i));
|
||||||
touchscreen_report_pos(ts->input_dev, &ts->prop,
|
touchscreen_report_pos(ts->input_dev, &ts->prop,
|
||||||
(finger_status & IST3038C_X_MASK) >>
|
FIELD_GET(IST3038C_X_MASK, finger_status),
|
||||||
IST3038C_X_SHIFT,
|
FIELD_GET(IST3038C_Y_MASK, finger_status),
|
||||||
finger_status & IST3038C_Y_MASK, 1);
|
true);
|
||||||
input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR,
|
input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR,
|
||||||
(finger_status & IST3038C_AREA_MASK) >>
|
FIELD_GET(IST3038C_AREA_MASK, finger_status));
|
||||||
IST3038C_AREA_SHIFT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
input_mt_sync_frame(ts->input_dev);
|
input_mt_sync_frame(ts->input_dev);
|
||||||
|
|
Loading…
Reference in a new issue