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