mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 4/4] input: gpio_keys: only use gpios in poller when not in use
Date: Wed, 21 Feb 2024 15:28:00 +0100	[thread overview]
Message-ID: <20240221142800.1958810-5-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20240221142800.1958810-1-s.hauer@pengutronix.de>

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

Signed-off-by: Sascha Hauer <s.hauer@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




  parent reply	other threads:[~2024-02-21 14:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-21 14:27 [PATCH 0/4] make I2C GPIO expander provided buttons work Sascha Hauer
2024-02-21 14:27 ` [PATCH 1/4] gpio: add slice support Sascha Hauer
2024-02-21 14:27 ` [PATCH 2/4] gpio: pca953x: depend on i2c slice Sascha Hauer
2024-02-21 14:27 ` [PATCH 3/4] input: gpio_keys: limit poll rate Sascha Hauer
2024-02-21 14:28 ` Sascha Hauer [this message]
2024-02-23  7:32 ` [PATCH 0/4] make I2C GPIO expander provided buttons work Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240221142800.1958810-5-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox