From: Jonas Rebmann <jre@pengutronix.de>
To: Sascha Hauer <s.hauer@pengutronix.de>,
BAREBOX <barebox@lists.infradead.org>
Cc: Jonas Rebmann <jre@pengutronix.de>
Subject: [PATCH 0/2] input: Supersede input_key_get_status() with input_is_key_pressed()
Date: Thu, 07 May 2026 13:10:38 +0200 [thread overview]
Message-ID: <20260507-input_is_key_pressed-v1-0-fc701980cb37@pengutronix.de> (raw)
Reading a GPIO button via gpio-keys can be preferable over direct GPIO
access as gpio-keys abstracts away from GPIO hardware via the
devicetree, consistently across barebox and linux.
Trying to read a single key state analogous to prt_imx6_init_prtvt7
failed as input_key_get_status should have been provided with the
keycode in question plus one to ensure a large enough bitfield to
contain the desired key state.
The correct way of reading a single key state via the
input_key_get_status() interface is as complicated as
bool is_button_pressed(int key) {
unsigned long *keys;
bool pressed;
keys = bitmap_xzalloc(key + 1);
input_key_get_status(keys, key + 1);
pressed = test_bit(key, keys);
free(keys);
return pressed;
}
This series implements a simple way to read the state of a single key
directly in the input driver.
As this can easily be invoked twice to check for a key combination,
replace this single occurence of input_key_get_status() with
input_is_key_pressed().
While those changes where thoroughly tested on a board with boardcode
very similar to protonic-imx6, the change to protonic-imx6 itself is
untested.
I suppose we have to keep input_key_get_status() for now for backwards
compatibility with downstream board code?
Signed-off-by: Jonas Rebmann <jre@pengutronix.de>
---
Jonas Rebmann (2):
input: add input_is_key_pressed() to read single key
ARM: boards: protonic-imx6: use input_is_key_pressed()
arch/arm/boards/protonic-imx6/board.c | 8 +-------
drivers/input/input.c | 14 ++++++++++++++
include/input/input.h | 1 +
3 files changed, 16 insertions(+), 7 deletions(-)
---
base-commit: 7a178f01f6e25474a5eb6e071ca479076b8d4d92
change-id: 20260507-input_is_key_pressed-4472a8a29980
Best regards,
--
Jonas Rebmann <jre@pengutronix.de>
next reply other threads:[~2026-05-07 11:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-07 11:10 Jonas Rebmann [this message]
2026-05-07 11:10 ` [PATCH 1/2] input: add input_is_key_pressed() to read single key Jonas Rebmann
2026-05-07 11:10 ` [PATCH 2/2] ARM: boards: protonic-imx6: use input_is_key_pressed() Jonas Rebmann
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=20260507-input_is_key_pressed-v1-0-fc701980cb37@pengutronix.de \
--to=jre@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=s.hauer@pengutronix.de \
/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