[U-Boot] [PATCH] usb: kbd: don't fail with iomux
Rob Clark
robdclark at gmail.com
Thu Aug 3 19:56:24 UTC 2017
On Thu, Aug 3, 2017 at 3:37 PM, Simon Glass <sjg at chromium.org> wrote:
> Hi Rob,
>
> On 3 August 2017 at 13:22, Rob Clark <robdclark at 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.
>>
>> This fixes an issue with usbkbd on dragonboard410c with distro-
>> bootcmd, where stdin is not set (so stdinname is null).
>
> Is this version 2?
yes, this is the actual v2 (note the fake v2 I sent earlier today)
>>
>> Signed-off-by: Rob Clark <robdclark at gmail.com>
>> ---
>> common/usb_kbd.c | 15 +++++++++++++++
>> 1 file changed, 15 insertions(+)
>>
>> diff --git a/common/usb_kbd.c b/common/usb_kbd.c
>> index d2d29cc98f..703dd748f5 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;
>> + /*
>> + * 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)) {
>> + char *newstdin = malloc(strlen(stdinname) + strlen(","DEVNAME) + 1);
>> + sprintf(newstdin, "%s,"DEVNAME, stdinname);
>> + stdinname = newstdin;
>> + } else if (!stdinname) {
>> + stdinname = devname;
>> + }
>> error = iomux_doenv(stdin, stdinname);
>> + if (stdinname != devname)
>> + free(stdinname);
>
> Are you sure that free() will work? It looks like it is intended to
> free newstdin. I think it would be better to have a boolean for
> whether to free(), instead.
oh, that's true.. on v1 you would always go down one or the other leg
of the if/else, which is no longer the case
BR,
-R
>> if (error)
>> return error;
>> #else
>> --
>> 2.13.0
>>
>
> Regards,
> Simon
More information about the U-Boot
mailing list