public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] usb: kbd: don't fail with iomux (v3)
@ 2017-08-04 12:51 Rob Clark
  2017-08-04 13:16 ` Bin Meng
  0 siblings, 1 reply; 9+ messages in thread
From: Rob Clark @ 2017-08-04 12:51 UTC (permalink / raw)
  To: u-boot

stdin might not be set, which would cause iomux_doenv() to fail
therefore causing probe_usb_keyboard() to fail.  Furthermore if we do
have iomux enabled, the sensible thing (in terms of user experience)
would be to simply add ourselves to the list of stdin devices.

This fixes an issue with usbkbd on dragonboard410c with distro-
bootcmd, where stdin is not set (so stdinname is null).

Signed-off-by: Rob Clark <robdclark@gmail.com>
---
v2: address Bin's review comments
v3: fix fail with free()ing if usbkbd is already in stdin env variable
    pointed out by Simon

(the real v3 this time)

 common/usb_kbd.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/common/usb_kbd.c b/common/usb_kbd.c
index d2d29cc98f..d71eae61ec 100644
--- a/common/usb_kbd.c
+++ b/common/usb_kbd.c
@@ -517,7 +517,22 @@ static int probe_usb_keyboard(struct usb_device *dev)
 
 	stdinname = getenv("stdin");
 #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)
 		return error;
 #else
-- 
2.13.0

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-08-13 21:37 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-04 12:51 [U-Boot] [PATCH] usb: kbd: don't fail with iomux (v3) Rob Clark
2017-08-04 13:16 ` Bin Meng
2017-08-06  5:16   ` Simon Glass
2017-08-06 10:41     ` Rob Clark
2017-08-06 10:53       ` Bin Meng
2017-08-06 11:58     ` Rob Clark
2017-08-13 15:35       ` Simon Glass
2017-08-13 18:07         ` Rob Clark
2017-08-13 21:37           ` Simon Glass

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox