diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2024-04-02 15:50:33 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2024-04-03 13:37:54 +0200 |
commit | 40db06326f87cd75fee1d147376e54852df09aba (patch) | |
tree | 230e509ccbac9346f1fcd17aa5befc4e287a91c8 | |
parent | ec521e914b412d41834ba010b84006e449f4e286 (diff) | |
download | barebox-40db06326f87cd75fee1d147376e54852df09aba.tar.gz barebox-40db06326f87cd75fee1d147376e54852df09aba.tar.xz |
input: add CONFIG_INPUT_EVBUG debug option
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>
Link: https://lore.barebox.org/20240402135035.3700601-3-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r-- | drivers/input/Kconfig | 11 | ||||
-rw-r--r-- | drivers/input/input.c | 11 |
2 files changed, 22 insertions, 0 deletions
diff --git a/drivers/input/Kconfig b/drivers/input/Kconfig index 52234c0ecc..01e0b722c2 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 deef5ddd22..1a47929351 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 |