diff mbox series

[v5,2/7] Input: matrix_keypad - add function for reading row state

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

Commit Message

Markus Burri Jan. 10, 2025, 5:49 a.m. UTC
Move the evaluation of a row state into separate function.
It will be also used by a change later in this series.

Signed-off-by: Markus Burri <markus.burri@mt.com>

---
 drivers/input/keyboard/matrix_keypad.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

Comments

Manuel Traut Feb. 19, 2025, 4:40 p.m. UTC | #1
On Fri, Jan 10, 2025 at 06:49:01AM +0100, Markus Burri wrote:
> Move the evaluation of a row state into separate function.
> It will be also used by a change later in this series.
> 
> Signed-off-by: Markus Burri <markus.burri@mt.com>

Reviewed-by: Manuel Traut <manuel.traut@mt.com>

> 
> ---
>  drivers/input/keyboard/matrix_keypad.c | 14 +++++++++++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/input/keyboard/matrix_keypad.c b/drivers/input/keyboard/matrix_keypad.c
> index 5571d2e..90148d3 100644
> --- a/drivers/input/keyboard/matrix_keypad.c
> +++ b/drivers/input/keyboard/matrix_keypad.c
> @@ -100,6 +100,16 @@ static void disable_row_irqs(struct matrix_keypad *keypad)
>  		disable_irq_nosync(keypad->row_irqs[i]);
>  }
>  
> +static uint32_t read_row_state(struct matrix_keypad *keypad)
> +{
> +	int row;
> +	u32 row_state = 0;

uint32_t row_state = 0;

would look more consistent.

> +
> +	for (row = 0; row < keypad->num_row_gpios; row++)
> +		row_state |= row_asserted(keypad, row) ? BIT(row) : 0;
> +	return row_state;
> +}
> +
>  /*
>   * This gets the keys from keyboard and reports it to input subsystem
>   */
> @@ -125,9 +135,7 @@ static void matrix_keypad_scan(struct work_struct *work)
>  
>  		activate_col(keypad, col, true);
>  
> -		for (row = 0; row < keypad->num_row_gpios; row++)
> -			new_state[col] |=
> -				row_asserted(keypad, row) ? BIT(row) : 0;
> +		new_state[col] = read_row_state(keypad);
>  
>  		activate_col(keypad, col, false);
>  	}
> -- 
> 2.39.5
>
diff mbox series

Patch

diff --git a/drivers/input/keyboard/matrix_keypad.c b/drivers/input/keyboard/matrix_keypad.c
index 5571d2e..90148d3 100644
--- a/drivers/input/keyboard/matrix_keypad.c
+++ b/drivers/input/keyboard/matrix_keypad.c
@@ -100,6 +100,16 @@  static void disable_row_irqs(struct matrix_keypad *keypad)
 		disable_irq_nosync(keypad->row_irqs[i]);
 }
 
+static uint32_t read_row_state(struct matrix_keypad *keypad)
+{
+	int row;
+	u32 row_state = 0;
+
+	for (row = 0; row < keypad->num_row_gpios; row++)
+		row_state |= row_asserted(keypad, row) ? BIT(row) : 0;
+	return row_state;
+}
+
 /*
  * This gets the keys from keyboard and reports it to input subsystem
  */
@@ -125,9 +135,7 @@  static void matrix_keypad_scan(struct work_struct *work)
 
 		activate_col(keypad, col, true);
 
-		for (row = 0; row < keypad->num_row_gpios; row++)
-			new_state[col] |=
-				row_asserted(keypad, row) ? BIT(row) : 0;
+		new_state[col] = read_row_state(keypad);
 
 		activate_col(keypad, col, false);
 	}