From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: lgo@pengutronix.de, Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 2/4] input: add CONFIG_INPUT_EVBUG debug option
Date: Tue, 2 Apr 2024 15:50:33 +0200 [thread overview]
Message-ID: <20240402135035.3700601-3-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20240402135035.3700601-1-a.fatoum@pengutronix.de>
Misconfigured pull-ups may cause the barebox boot to abort. To help
debugging such issues, add a CONFIG_INPUT_EVBUG option similar to Linux,
which will print a debug message every time a key event is reported.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
drivers/input/Kconfig | 11 +++++++++++
drivers/input/input.c | 11 +++++++++++
2 files changed, 22 insertions(+)
diff --git a/drivers/input/Kconfig b/drivers/input/Kconfig
index 52234c0ecc49..01e0b722c20f 100644
--- a/drivers/input/Kconfig
+++ b/drivers/input/Kconfig
@@ -12,6 +12,17 @@ config INPUT
config INPUT_MATRIXKMAP
bool
+config INPUT_EVBUG
+ bool "Event debugging"
+ help
+ Say Y here if you have a problem with the input subsystem and
+ want all events (keypresses), to be output to
+ the barebox log. While this is useful for debugging, it's also
+ a security threat - your keypresses include your passwords, of
+ course and could be visible to userspace if pstore is configured.
+
+ If unsure, say N.
+
config KEYBOARD_GPIO
bool "GPIO Buttons"
depends on GENERIC_GPIO
diff --git a/drivers/input/input.c b/drivers/input/input.c
index deef5ddd22a7..1a4792935114 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -1,5 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-only
+#define pr_fmt(fmt) "input: " fmt
+
#include <common.h>
#include <init.h>
#include <kfifo.h>
@@ -33,6 +35,15 @@ void input_report_key_event(struct input_device *idev, unsigned int code, int va
if (code > KEY_MAX)
return;
+ /*
+ * We don't use pr_debug here as we want to output the message
+ * to the log, even if CONFIG_COMPILE_LOGLEVEL < MSG_DEBUG and
+ * the DEBUG mcro wasn't defined for the file.
+ */
+ if (IS_ENABLED(CONFIG_INPUT_EVBUG))
+ pr_print(MSG_DEBUG, "Event. Dev: %s, Type: %d, Code: %d, Value: %d\n",
+ dev_name(idev->parent), EV_KEY, code, value);
+
if (value)
set_bit(code, idev->keys);
else
--
2.39.2
next prev parent reply other threads:[~2024-04-02 15:04 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-02 13:50 [PATCH 0/4] " Ahmad Fatoum
2024-04-02 13:50 ` [PATCH 1/4] input: record parent device at registration time Ahmad Fatoum
2024-04-02 13:50 ` Ahmad Fatoum [this message]
2024-04-02 13:50 ` [PATCH 3/4] input: imx-keypad: remove now-duplicate debug messages Ahmad Fatoum
2024-04-02 14:06 ` Ahmad Fatoum
2024-04-03 11:40 ` Sascha Hauer
2024-04-02 13:50 ` [PATCH 4/4] input: gpio-keys: drop now-superfluous struct gpio_keys::dev Ahmad Fatoum
2024-04-03 11:39 ` [PATCH 0/4] input: add CONFIG_INPUT_EVBUG debug option 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=20240402135035.3700601-3-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=lgo@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