[PATCH 2/2] ARM: boards: protonic-imx6: use input_is_key_pressed()

Jonas Rebmann
2026-05-07T11:41:41Z

input_key_get_status() prepares a bitmap of the provided size. This
means that a keycode provided here is not actually contained in the
resulting bitmap and the test is guaranteed to fail at least if the
provided keycode is a multiple of sizeof(long)*8.

input_key_get_status(keys, KEY_CYCLEWINDOWS + 1) would have been
correct.

The use of xzalloc to allocate the bitmap is also incorrect,
bitmap_xzalloc(KEY_CYCLEWINDOWS + 1) would have been correct.

As bitmaps are composed of longs, the underlying array is always sized a
multiple of sizeof(long). Although the allocations are unaffected by
this as they are a multiple of sizeof(long) too, xzalloc only zeroes the
specified number of bytes resulting in a potentially nonzero bitmap.

Avoid those troubles altogether and use input_is_key_pressed() instead.

Signed-off-by: Jonas Rebmann <jre@pengutronix.de>
---
arch/arm/boards/protonic-imx6/board.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/arch/arm/boards/protonic-imx6/board.c b/arch/arm/boards/protonic-imx6/board.c
index 3bb2632693..174ccf70bd 100644
--- a/arch/arm/boards/protonic-imx6/board.c
+++ b/arch/arm/boards/protonic-imx6/board.c
@@ -740,21 +740,15 @@ static int prt_imx6_init_kvg_yaco(struct prt_imx6_priv *priv)

static int prt_imx6_init_prtvt7(struct prt_imx6_priv *priv)
{
- unsigned long *keys;
-
of_devices_ensure_probed_by_compatible("gpio-keys");

/*
* Prefer USB-boot and enable autoboot with timeout when CYCLE-F6 key
* combination is pressed.
*/
- keys = xzalloc((KEY_CYCLEWINDOWS / 8) + 1);
- input_key_get_status(keys, KEY_CYCLEWINDOWS);
-
- if (!(test_bit(KEY_CYCLEWINDOWS, keys) && test_bit(KEY_F6, keys)))
+ if (!(input_is_key_pressed(KEY_CYCLEWINDOWS) && input_is_key_pressed(KEY_F6)))
priv->no_usb_check = 1;

- free(keys);
return 0;
}

--
2.53.0.610.g30c4861dc6