input: kbd_matrix: fix possible race condition
Fix a possible race condition in the keyboard matrix library where a key would get pressed between the last read and reenabling the (edge sensitive) interrupt and the even would be lost. The window for this to happen is very narrow and had to artificially add a sleep to reproduce it. Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
This commit is contained in:
parent
ffbd0397dd
commit
ecce235322
1 changed files with 7 additions and 0 deletions
|
@ -291,6 +291,13 @@ static void input_kbd_matrix_polling_thread(void *arg1, void *unused2, void *unu
|
|||
input_kbd_matrix_drive_column(dev, INPUT_KBD_MATRIX_COLUMN_DRIVE_ALL);
|
||||
api->set_detect_mode(dev, true);
|
||||
|
||||
/* Check the rows again after enabling the interrupt to catch
|
||||
* any potential press since the last read.
|
||||
*/
|
||||
if (api->read_row(dev) != 0) {
|
||||
input_kbd_matrix_poll_start(dev);
|
||||
}
|
||||
|
||||
k_sem_take(&data->poll_lock, K_FOREVER);
|
||||
LOG_DBG("scan start");
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue