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 2/2] ARM: boards: protonic-imx6: use input_is_key_pressed()
Date: Thu, 07 May 2026 13:10:40 +0200 [thread overview]
Message-ID: <20260507-input_is_key_pressed-v1-2-fc701980cb37@pengutronix.de> (raw)
In-Reply-To: <20260507-input_is_key_pressed-v1-0-fc701980cb37@pengutronix.de>
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
prev parent reply other threads:[~2026-05-07 11:41 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-07 11:10 [PATCH 0/2] input: Supersede input_key_get_status() with input_is_key_pressed() Jonas Rebmann
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 ` Jonas Rebmann [this message]
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-2-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