Skip to contentSkip to conversation

usb: kbd: don't fail with iomux

PATCH New Rob Clark 2 participants 4 messages Jul 21, 2017 – Jul 23, 2017

lore
Share & tools
lore

Rob Clark

author
#0 lore raw

PATCH 1/2 usb: kbd: don't fail with iomux

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.

---
 common/usb_kbd.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
common/usb_kbd.c +14 -0
index d2d29cc98f..72cf78abd4 100644
@@ -517,7 +517,21 @@ static int probe_usb_keyboard(struct usb_device *dev)
 
 	stdinname = getenv("stdin");
 #if CONFIG_IS_ENABLED(CONSOLE_MUX)
+	char *devname = DEVNAME;
+	/* 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) {
+		char *newstdin = malloc(strlen(stdinname) + strlen(","DEVNAME) + 1);
+		sprintf(newstdin, "%s,"DEVNAME, stdinname);
+		stdinname = newstdin;
+	} else {
+		stdinname = devname;
+	}
 	error = iomux_doenv(stdin, stdinname);
+	if (stdinname != devname)
+		free(stdinname);
 	if (error)
 		return error;
 #else
Signature · 1 line
2.13.0
author
#1 lore raw

PATCH 2/2 usb: kbd: add missing \n

---
 common/usb_kbd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
common/usb_kbd.c +1 -1
index 72cf78abd4..615f8f88cd 100644
@@ -654,7 +654,7 @@ static int usb_kbd_remove(struct udevice *dev)
 
 	return 0;
 err:
-	printf("%s: warning, ret=%d", __func__, ret);
+	printf("%s: warning, ret=%d\n", __func__, ret);
 	return ret;
 }
 
Signature · 1 line
2.13.0
#3 lore raw

PATCH 1/2 usb: kbd: don't fail with iomux

In reply to Rob Clark

Hi Rob,

Quoted 15 lines · Rob Clark

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.

---
 common/usb_kbd.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
common/usb_kbd.c +0 -0
index d2d29cc98f..72cf78abd4 100644

common/usb_kbd.c static int probe_usb_keyboard(struct usb_device *dev) · line 521

Quoted 5 lines
common/usb_kbd.c +2 -0
@@ -517,7 +517,21 @@ static int probe_usb_keyboard(struct usb_device *dev)
 
        stdinname = getenv("stdin");
 #if CONFIG_IS_ENABLED(CONSOLE_MUX)
+       char *devname = DEVNAME;
+       /* stdin might not be set yet.. either way, with console-mux the

nits: /* should be on a single line

common/usb_kbd.c static int probe_usb_keyboard(struct usb_device *dev) · line 527

Quoted 6 lines
common/usb_kbd.c +6 -0
+        * sensible thing to do is add ourselves to the list of stdio
+        * devices:
+        */
+       if (stdinname) {
+               char *newstdin = malloc(strlen(stdinname) + strlen(","DEVNAME) + 1);
+               sprintf(newstdin, "%s,"DEVNAME, stdinname);

We should check whether are are already in the stdin, if not, then add by ourselves.

common/usb_kbd.c static int probe_usb_keyboard(struct usb_device *dev)

Quoted 11 lines
common/usb_kbd.c +6 -1
+               stdinname = newstdin;
+       } else {
+               stdinname = devname;
+       }
        error = iomux_doenv(stdin, stdinname);
+       if (stdinname != devname)
+               free(stdinname);
        if (error)
                return error;
 #else
--

Regards,
Bin