diff mbox series

[1/6] Input: matrix_keypad - move gpio-row init to the init part

Message ID 20241031063004.69956-2-markus.burri@mt.com
State New
Headers show
Series Input: matrix-keypad: Various performance improvements | expand

Commit Message

Markus Burri Oct. 31, 2024, 6:29 a.m. UTC
If the matrix keypad is wired over a slow interface
(e.g. a gpio-expansion over i2c), the scan can take a longer time.
Move the initialisation of row gpio from scan to the init function will
reduce the scan time and therefore increase scan performance.

Signed-off-by: Markus Burri <markus.burri@mt.com>
Reviewed-by: Manuel Traut <manuel.traut@mt.com>
Tested-by: HeDong Zhao <hedong.zhao@mt.com>
---
 drivers/input/keyboard/matrix_keypad.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/drivers/input/keyboard/matrix_keypad.c b/drivers/input/keyboard/matrix_keypad.c
index 3c38bae..a2ec9f6 100644
--- a/drivers/input/keyboard/matrix_keypad.c
+++ b/drivers/input/keyboard/matrix_keypad.c
@@ -118,9 +118,6 @@  static void matrix_keypad_scan(struct work_struct *work)
 
 	memset(new_state, 0, sizeof(new_state));
 
-	for (row = 0; row < keypad->num_row_gpios; row++)
-		gpiod_direction_input(keypad->row_gpios[row]);
-
 	/* assert each column and read the row status out */
 	for (col = 0; col < keypad->num_col_gpios; col++) {
 
@@ -326,6 +323,8 @@  static int matrix_keypad_init_gpio(struct platform_device *pdev,
 
 		if (active_low ^ gpiod_is_active_low(keypad->row_gpios[i]))
 			gpiod_toggle_active_low(keypad->row_gpios[i]);
+
+		gpiod_direction_input(keypad->row_gpios[i]);
 	}
 
 	return 0;