[PATCH 0/2] input: Supersede input_key_get_status() with input_is_key_pressed()

Jonas Rebmann
2026-05-07T11:12:23Z

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>