[PATCH 4/4] input: gpio_keys: only use gpios in poller when not in use

Sascha Hauer s.hauer at pengutronix.de
Wed Feb 21 06:28:00 PST 2024


Before reading GPIOs in a poller check if they are available.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 drivers/input/gpio_keys.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/input/gpio_keys.c b/drivers/input/gpio_keys.c
index fd3995d01f..c23d20563c 100644
--- a/drivers/input/gpio_keys.c
+++ b/drivers/input/gpio_keys.c
@@ -40,6 +40,13 @@ static void gpio_key_poller(void *data)
 	struct gpio_key *gb;
 	int i, val;
 
+	for (i = 0; i < gk->nbuttons; i++) {
+		gb = &gk->buttons[i];
+
+		if (gpio_slice_acquired(gb->gpio))
+			goto out;
+	}
+
 	for (i = 0; i < gk->nbuttons; i++) {
 
 		gb = &gk->buttons[i];
@@ -58,7 +65,7 @@ static void gpio_key_poller(void *data)
 			gb->previous_state = val;
 		}
 	}
-
+out:
 	poller_call_async(&gk->poller, 10 * MSECOND, gpio_key_poller, gk);
 }
 
-- 
2.39.2




More information about the barebox mailing list