uboot-tools/usb-kbd-fixes.patch

116 lines
2.9 KiB
Diff
Raw Normal View History

2018-12-04 15:40:35 +00:00
From a49845f198af088c4e5e0019edbf519344d78c97 Mon Sep 17 00:00:00 2001
2017-12-22 01:35:59 +00:00
From: Peter Robinson <pbrobinson@gmail.com>
2018-12-04 15:40:35 +00:00
Date: Tue, 4 Dec 2018 15:29:14 +0000
Subject: [PATCH] usb kbd fixes
2017-12-22 01:35:59 +00:00
Signed-off-by: Peter Robinson <pbrobinson@gmail.com>
---
2018-12-04 15:40:35 +00:00
common/usb_kbd.c | 66 +++++++++++++++++++++++++++++++++++------------
include/console.h | 2 --
2017-12-22 01:35:59 +00:00
2 files changed, 50 insertions(+), 18 deletions(-)
diff --git a/common/usb_kbd.c b/common/usb_kbd.c
2018-12-04 15:40:35 +00:00
index 020f0d4117f..47674ce4458 100644
--- a/common/usb_kbd.c
+++ b/common/usb_kbd.c
2018-12-04 15:40:35 +00:00
@@ -518,25 +518,59 @@ static int probe_usb_keyboard(struct usb_device *dev)
return error;
stdinname = env_get("stdin");
-#if CONFIG_IS_ENABLED(CONSOLE_MUX)
- error = iomux_doenv(stdin, stdinname);
- if (error)
- return error;
-#else
- /* Check if this is the standard input device. */
- if (strcmp(stdinname, DEVNAME))
- return 1;
+ if (CONFIG_IS_ENABLED(CONSOLE_MUX)) {
+ char *devname = DEVNAME;
+ char *newstdin = NULL;
+ /*
+ * stdin might not be set yet.. either way, with console-
+ * mux the sensible thing to do is add ourselves to the
+ * list of stdio devices:
+ */
+ if (stdinname && !strstr(stdinname, DEVNAME)) {
+ newstdin = malloc(strlen(stdinname) +
+ strlen(","DEVNAME) + 1);
+ sprintf(newstdin, "%s,"DEVNAME, stdinname);
+ stdinname = newstdin;
+ } else if (!stdinname) {
+ stdinname = devname;
+ }
+ error = iomux_doenv(stdin, stdinname);
+ free(newstdin);
+ if (error)
2017-12-22 01:35:59 +00:00
+ goto unregister_stdio;
+ } else {
+ /* Check if this is the standard input device. */
2017-12-22 01:35:59 +00:00
+ if (strcmp(stdinname, DEVNAME)) {
+ error = -1;
+ goto unregister_stdio;
+ }
- /* Reassign the console */
- if (overwrite_console())
- return 1;
+ /* Reassign the console */
2017-12-22 01:35:59 +00:00
+ if (overwrite_console()) {
+ error = -1;
+ goto unregister_stdio;
+ }
- error = console_assign(stdin, DEVNAME);
- if (error)
- return error;
-#endif
+ error = console_assign(stdin, DEVNAME);
+ if (error)
+ goto unregister_stdio;
2017-12-22 01:35:59 +00:00
+ }
+
2017-12-22 01:35:59 +00:00
+ return 0;
+unregister_stdio:
+ /*
+ * If probe fails, the device will be removed.. leaving dangling
+ * pointers if the stdio device is not unregistered. If u-boot
+ * is built without stdio_deregister(), just pretend to succeed
+ * in order to avoid dangling pointers.
+ */
+#if CONFIG_IS_ENABLED(SYS_STDIO_DEREGISTER)
+ stdio_deregister(DEVNAME, 1);
+ return error;
+#else
2017-12-22 01:35:59 +00:00
return 0;
+#endif
}
2018-12-04 15:40:35 +00:00
#if !CONFIG_IS_ENABLED(DM_USB)
@@ -642,7 +676,7 @@ static int usb_kbd_remove(struct udevice *dev)
2017-10-17 09:43:37 +00:00
return 0;
err:
- printf("%s: warning, ret=%d", __func__, ret);
+ printf("%s: warning, ret=%d\n", __func__, ret);
return ret;
}
2017-12-22 01:35:59 +00:00
diff --git a/include/console.h b/include/console.h
2018-12-04 15:40:35 +00:00
index e935c601f12..6382ec8e0d6 100644
2017-12-22 01:35:59 +00:00
--- a/include/console.h
+++ b/include/console.h
2018-12-04 15:40:35 +00:00
@@ -56,8 +56,6 @@ int console_announce_r(void);
2017-12-22 01:35:59 +00:00
/*
* CONSOLE multiplexing.
*/
-#ifdef CONFIG_CONSOLE_MUX
#include <iomux.h>
-#endif
#endif
2017-10-17 09:43:37 +00:00
--
2018-12-04 15:40:35 +00:00
2.19.2
2017-12-22 01:35:59 +00:00