2017-12-22 01:35:59 +00:00
|
|
|
From 1a8fa60aedff8a2368ac357a51dc15357065fabe Mon Sep 17 00:00:00 2001
|
|
|
|
From: Peter Robinson <pbrobinson@gmail.com>
|
|
|
|
Date: Tue, 5 Dec 2017 00:11:54 +0000
|
|
|
|
Subject: [PATCH 3/5] usb kbd fixes
|
2017-10-06 06:35:41 +00:00
|
|
|
|
2017-12-22 01:35:59 +00:00
|
|
|
Signed-off-by: Peter Robinson <pbrobinson@gmail.com>
|
2017-10-06 06:35:41 +00:00
|
|
|
---
|
2017-12-22 01:35:59 +00:00
|
|
|
common/usb_kbd.c | 66 +++++++++++++++++++++++++++++++++++++++++--------------
|
2017-10-06 06:35:41 +00:00
|
|
|
include/console.h | 2 --
|
2017-12-22 01:35:59 +00:00
|
|
|
2 files changed, 50 insertions(+), 18 deletions(-)
|
2017-10-06 06:35:41 +00:00
|
|
|
|
|
|
|
diff --git a/common/usb_kbd.c b/common/usb_kbd.c
|
2017-12-22 01:35:59 +00:00
|
|
|
index 8cbdba6ac2..82ad93f6ca 100644
|
2017-10-06 06:35:41 +00:00
|
|
|
--- a/common/usb_kbd.c
|
|
|
|
+++ b/common/usb_kbd.c
|
2017-12-22 01:35:59 +00:00
|
|
|
@@ -516,25 +516,59 @@ static int probe_usb_keyboard(struct usb_device *dev)
|
2017-10-06 06:35:41 +00:00
|
|
|
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;
|
2017-10-06 06:35:41 +00:00
|
|
|
+ } 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;
|
|
|
|
+ }
|
2017-10-06 06:35:41 +00:00
|
|
|
|
|
|
|
- /* 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;
|
|
|
|
+ }
|
2017-10-06 06:35:41 +00:00
|
|
|
|
|
|
|
- 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-10-06 06:35:41 +00:00
|
|
|
+
|
2017-12-22 01:35:59 +00:00
|
|
|
+ return 0;
|
|
|
|
|
2017-10-06 06:35:41 +00:00
|
|
|
+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;
|
2017-10-06 06:35:41 +00:00
|
|
|
+#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef CONFIG_DM_USB
|
2017-12-22 01:35:59 +00:00
|
|
|
@@ -640,7 +674,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
|
|
|
|
index cea29ed6dc..7dfd36d7d1 100644
|
|
|
|
--- a/include/console.h
|
|
|
|
+++ b/include/console.h
|
|
|
|
@@ -57,8 +57,6 @@ int console_announce_r(void);
|
|
|
|
/*
|
|
|
|
* CONSOLE multiplexing.
|
|
|
|
*/
|
|
|
|
-#ifdef CONFIG_CONSOLE_MUX
|
|
|
|
#include <iomux.h>
|
|
|
|
-#endif
|
|
|
|
|
|
|
|
#endif
|
2017-10-17 09:43:37 +00:00
|
|
|
--
|
2017-12-22 01:35:59 +00:00
|
|
|
2.14.3
|
|
|
|
|