[U-Boot] [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.
Signed-off-by: Rob Clark robdclark@gmail.com --- common/usb_kbd.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
diff --git a/common/usb_kbd.c b/common/usb_kbd.c index d2d29cc98f..72cf78abd4 100644 --- a/common/usb_kbd.c +++ b/common/usb_kbd.c @@ -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

Signed-off-by: Rob Clark robdclark@gmail.com --- common/usb_kbd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/common/usb_kbd.c b/common/usb_kbd.c index 72cf78abd4..615f8f88cd 100644 --- a/common/usb_kbd.c +++ b/common/usb_kbd.c @@ -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; }

On Sat, Jul 22, 2017 at 3:13 AM, Rob Clark robdclark@gmail.com wrote:
Signed-off-by: Rob Clark robdclark@gmail.com
common/usb_kbd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Bin Meng bmeng.cn@gmail.com

Hi Rob,
On Sat, Jul 22, 2017 at 3:13 AM, Rob Clark robdclark@gmail.com wrote:
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.
Signed-off-by: Rob Clark robdclark@gmail.com
common/usb_kbd.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
diff --git a/common/usb_kbd.c b/common/usb_kbd.c index d2d29cc98f..72cf78abd4 100644 --- a/common/usb_kbd.c +++ b/common/usb_kbd.c @@ -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
* 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.
stdinname = newstdin;
} else {
stdinname = devname;
} error = iomux_doenv(stdin, stdinname);
if (stdinname != devname)
free(stdinname); if (error) return error;
#else
Regards, Bin
participants (2)
-
Bin Meng
-
Rob Clark