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: matrix_keypad - consolidate handling of clustered interrupt

Now that the driver stores interrupt numbers corresponding to individual
GPIOs in non-clustered mode, it is possible to unify handling of both
modes by storing clustered interrupt at position 0 and setting the
number of interrupts in this case to 1.

Link: https://lore.kernel.org/r/20240121053232.276968-2-dmitry.torokhov@gmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

+20 -43
+20 -43
drivers/input/keyboard/matrix_keypad.c
··· 27 27 const struct matrix_keypad_platform_data *pdata; 28 28 struct input_dev *input_dev; 29 29 unsigned int row_shift; 30 - unsigned int row_irqs[MATRIX_MAX_ROWS]; 31 30 32 - DECLARE_BITMAP(disabled_gpios, MATRIX_MAX_ROWS); 31 + unsigned int row_irqs[MATRIX_MAX_ROWS]; 32 + unsigned int num_row_irqs; 33 + DECLARE_BITMAP(wakeup_enabled_irqs, MATRIX_MAX_ROWS); 33 34 34 35 uint32_t last_key_state[MATRIX_MAX_COLS]; 35 36 struct delayed_work work; ··· 87 86 88 87 static void enable_row_irqs(struct matrix_keypad *keypad) 89 88 { 90 - const struct matrix_keypad_platform_data *pdata = keypad->pdata; 91 89 int i; 92 90 93 - if (pdata->clustered_irq > 0) 94 - enable_irq(pdata->clustered_irq); 95 - else { 96 - for (i = 0; i < pdata->num_row_gpios; i++) 97 - enable_irq(keypad->row_irqs[i]); 98 - } 91 + for (i = 0; i < keypad->num_row_irqs; i++) 92 + enable_irq(keypad->row_irqs[i]); 99 93 } 100 94 101 95 static void disable_row_irqs(struct matrix_keypad *keypad) 102 96 { 103 - const struct matrix_keypad_platform_data *pdata = keypad->pdata; 104 97 int i; 105 98 106 - if (pdata->clustered_irq > 0) 107 - disable_irq_nosync(pdata->clustered_irq); 108 - else { 109 - for (i = 0; i < pdata->num_row_gpios; i++) 110 - disable_irq_nosync(keypad->row_irqs[i]); 111 - } 99 + for (i = 0; i < keypad->num_row_irqs; i++) 100 + disable_irq_nosync(keypad->row_irqs[i]); 112 101 } 113 102 114 103 /* ··· 224 233 225 234 static void matrix_keypad_enable_wakeup(struct matrix_keypad *keypad) 226 235 { 227 - const struct matrix_keypad_platform_data *pdata = keypad->pdata; 228 236 int i; 229 237 230 - if (pdata->clustered_irq > 0) { 231 - if (enable_irq_wake(pdata->clustered_irq) == 0) 232 - keypad->gpio_all_disabled = true; 233 - } else { 234 - 235 - for (i = 0; i < pdata->num_row_gpios; i++) 236 - if (!test_bit(i, keypad->disabled_gpios)) 237 - if (enable_irq_wake(keypad->row_irqs[i]) == 0) 238 - __set_bit(i, keypad->disabled_gpios); 239 - } 238 + for_each_clear_bit(i, keypad->wakeup_enabled_irqs, keypad->num_row_irqs) 239 + if (enable_irq_wake(keypad->row_irqs[i]) == 0) 240 + __set_bit(i, keypad->wakeup_enabled_irqs); 240 241 } 241 242 242 243 static void matrix_keypad_disable_wakeup(struct matrix_keypad *keypad) 243 244 { 244 - const struct matrix_keypad_platform_data *pdata = keypad->pdata; 245 245 int i; 246 246 247 - if (pdata->clustered_irq > 0) { 248 - if (keypad->gpio_all_disabled) { 249 - disable_irq_wake(pdata->clustered_irq); 250 - keypad->gpio_all_disabled = false; 251 - } 252 - } else { 253 - for (i = 0; i < pdata->num_row_gpios; i++) 254 - if (test_and_clear_bit(i, keypad->disabled_gpios)) 255 - disable_irq_wake(keypad->row_irqs[i]); 247 + for_each_set_bit(i, keypad->wakeup_enabled_irqs, keypad->num_row_irqs) { 248 + disable_irq_wake(keypad->row_irqs[i]); 249 + __clear_bit(i, keypad->wakeup_enabled_irqs); 256 250 } 257 251 } 258 252 ··· 311 335 "Unable to acquire clustered interrupt\n"); 312 336 goto err_free_rows; 313 337 } 338 + 339 + keypad->row_irqs[0] = pdata->clustered_irq; 340 + keypad->num_row_irqs = 1; 314 341 } else { 315 342 for (i = 0; i < pdata->num_row_gpios; i++) { 316 343 irq = gpio_to_irq(pdata->row_gpios[i]); ··· 339 360 340 361 keypad->row_irqs[i] = irq; 341 362 } 363 + 364 + keypad->num_row_irqs = pdata->num_row_gpios; 342 365 } 343 366 344 367 /* initialized as disabled - enabled by input->open */ ··· 367 386 const struct matrix_keypad_platform_data *pdata = keypad->pdata; 368 387 int i; 369 388 370 - if (pdata->clustered_irq > 0) { 371 - free_irq(pdata->clustered_irq, keypad); 372 - } else { 373 - for (i = 0; i < pdata->num_row_gpios; i++) 374 - free_irq(keypad->row_irqs[i], keypad); 375 - } 389 + for (i = 0; i < keypad->num_row_irqs; i++) 390 + free_irq(keypad->row_irqs[i], keypad); 376 391 377 392 for (i = 0; i < pdata->num_row_gpios; i++) 378 393 gpio_free(pdata->row_gpios[i]);