[PATCH 2/4] input: add CONFIG_INPUT_EVBUG debug option

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx>
---
 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





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux