Skip to content

Commit 0a73192

Browse files
mitagregkh
authored andcommitted
Input: mpr121 - handle multiple bits change of status register
[ Upstream commit 08fea55e37f58371bffc5336a59e55d1f155955a ] This driver reports input events on their interrupts which are triggered by the sensor's status register changes. But only single bit change is reported in the interrupt handler. So if there are multiple bits are changed at almost the same time, other press or release events are ignored. This fixes it by detecting all changed bits in the status register. Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Signed-off-by: Sasha Levin <alexander.levin@verizon.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent ffa6332 commit 0a73192

1 file changed

Lines changed: 14 additions & 9 deletions

File tree

drivers/input/keyboard/mpr121_touchkey.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ static irqreturn_t mpr_touchkey_interrupt(int irq, void *dev_id)
8787
struct mpr121_touchkey *mpr121 = dev_id;
8888
struct i2c_client *client = mpr121->client;
8989
struct input_dev *input = mpr121->input_dev;
90-
unsigned int key_num, key_val, pressed;
90+
unsigned long bit_changed;
91+
unsigned int key_num;
9192
int reg;
9293

9394
reg = i2c_smbus_read_byte_data(client, ELE_TOUCH_STATUS_1_ADDR);
@@ -105,18 +106,22 @@ static irqreturn_t mpr_touchkey_interrupt(int irq, void *dev_id)
105106

106107
reg &= TOUCH_STATUS_MASK;
107108
/* use old press bit to figure out which bit changed */
108-
key_num = ffs(reg ^ mpr121->statusbits) - 1;
109-
pressed = reg & (1 << key_num);
109+
bit_changed = reg ^ mpr121->statusbits;
110110
mpr121->statusbits = reg;
111+
for_each_set_bit(key_num, &bit_changed, mpr121->keycount) {
112+
unsigned int key_val, pressed;
111113

112-
key_val = mpr121->keycodes[key_num];
114+
pressed = reg & BIT(key_num);
115+
key_val = mpr121->keycodes[key_num];
113116

114-
input_event(input, EV_MSC, MSC_SCAN, key_num);
115-
input_report_key(input, key_val, pressed);
116-
input_sync(input);
117+
input_event(input, EV_MSC, MSC_SCAN, key_num);
118+
input_report_key(input, key_val, pressed);
119+
120+
dev_dbg(&client->dev, "key %d %d %s\n", key_num, key_val,
121+
pressed ? "pressed" : "released");
117122

118-
dev_dbg(&client->dev, "key %d %d %s\n", key_num, key_val,
119-
pressed ? "pressed" : "released");
123+
}
124+
input_sync(input);
120125

121126
out:
122127
return IRQ_HANDLED;

0 commit comments

Comments
 (0)