From patchwork Mon Aug 7 19:51:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 798840 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="nGBicyVz"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3xR7TD67sNz9s76 for ; Tue, 8 Aug 2017 05:51:44 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 7926CC21D94; Mon, 7 Aug 2017 19:51:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 2D0CCC21C4E; Mon, 7 Aug 2017 19:51:36 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id AC680C21C4E; Mon, 7 Aug 2017 19:51:35 +0000 (UTC) Received: from mail-qk0-f194.google.com (mail-qk0-f194.google.com [209.85.220.194]) by lists.denx.de (Postfix) with ESMTPS id 2F5CAC21C3F for ; Mon, 7 Aug 2017 19:51:35 +0000 (UTC) Received: by mail-qk0-f194.google.com with SMTP id a77so1444969qkb.2 for ; Mon, 07 Aug 2017 12:51:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=gwwb1uzkBhgo9/y+YCowSmXNr0cFzhF/Jv0EiGlLjyo=; b=nGBicyVzA3OLcG/WhKGbrgfUQvnoqzFDKuEYGkmQJJMC6CGgAZSGTv1FWjhu79dw4Y OX9PRJALJufv3Q/4BE9wqC8/BnCqxVR1z1Usx03Vv5A3FPtmJJmpcYMt6E0S6CbA+B81 0tc4Lu844tQ3VIEdVQGNXtmtxeWMn94+HmCBDGsLzvhVP8A0R7Z/oX3Xlyu9ilnMGlSr umhmeFIjBowCR6PRbQW9qoaVT6Q7ZbemDRj+MFAj/Yu1NNHyJo7gxvH+TvAwkORY/uV9 BkGnCWUXmU9skOLV27pko/4kO7Ocg4BGFXWGLLLkwF+awc6hT+SNo8L8rTgGLXkvAnSe hEUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=gwwb1uzkBhgo9/y+YCowSmXNr0cFzhF/Jv0EiGlLjyo=; b=XKboRLh968rq8Nyyk2AuIWCGt9IUTdQfgY3mpxqQBr4KloAWuOV16GU9P5IU4AkgTw 3Hov6NHhwqLni3nFIz6ioNXi1qVqSazl5upTs4JNPOfqBopOOG382nOvyVhUhamRPT8k pYJvrnvBQcNbSimIhzyto4kh2xfIlv4Ny2AlfDUUtMERKbtwyOuAo9zeUDJ7P43MyiGs bcwlEbV29LdZxjBl9a07kfUwUC5+6d2xSUA9VX9+9yEXFu8u7hI0iX2Q7thzBbyqG6ur TQM3J9p/lVAAY+498uTyqtk7B8qbBJ/xbaigiNR2jPgWI0elfDaB6Be03sqCjHJk4hDm T3bw== X-Gm-Message-State: AHYfb5h2ycu2eeWjnZYP3GHePLw0n3RyWsbauvYawovA9HwQ4B0GI5UX 90oY7EolODl4GgPExmo= X-Received: by 10.55.73.135 with SMTP id w129mr2295409qka.249.1502135493579; Mon, 07 Aug 2017 12:51:33 -0700 (PDT) Received: from localhost ([144.121.20.162]) by smtp.gmail.com with ESMTPSA id k90sm6269932qte.44.2017.08.07.12.51.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Aug 2017 12:51:32 -0700 (PDT) From: Rob Clark To: U-Boot Mailing List Date: Mon, 7 Aug 2017 15:51:23 -0400 Message-Id: <20170807195129.10638-1-robdclark@gmail.com> X-Mailer: git-send-email 2.13.0 Subject: [U-Boot] [PATCH v4] usb: kbd: don't fail with iomux X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "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 Reviewed-by: Bin Meng --- v2: address Bin's review comments v3: fix fail with free()ing if usbkbd is already in stdin env variable pointed out by Simon v4: use if (CONFIG_IS_ENABLED(CONSOLE_MUX)) { ... } common/usb_kbd.c | 46 +++++++++++++++++++++++++++++++--------------- include/console.h | 2 -- 2 files changed, 31 insertions(+), 17 deletions(-) diff --git a/common/usb_kbd.c b/common/usb_kbd.c index d2d29cc98f..8edeb6c4f5 100644 --- a/common/usb_kbd.c +++ b/common/usb_kbd.c @@ -516,23 +516,39 @@ static int probe_usb_keyboard(struct usb_device *dev) return error; stdinname = getenv("stdin"); -#if CONFIG_IS_ENABLED(CONSOLE_MUX) - error = iomux_doenv(stdin, stdinname); - if (error) - return error; -#else - /* Check if this is the standard input device. */ - if (strcmp(stdinname, DEVNAME)) - return 1; + 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 { + /* Check if this is the standard input device. */ + if (strcmp(stdinname, DEVNAME)) + return 1; - /* Reassign the console */ - if (overwrite_console()) - return 1; + /* Reassign the console */ + if (overwrite_console()) + return 1; - error = console_assign(stdin, DEVNAME); - if (error) - return error; -#endif + error = console_assign(stdin, DEVNAME); + if (error) + return error; + } return 0; } diff --git a/include/console.h b/include/console.h index cea29ed6dc..7dfd36d7d1 100644 --- a/include/console.h +++ b/include/console.h @@ -57,8 +57,6 @@ int console_announce_r(void); /* * CONSOLE multiplexing. */ -#ifdef CONFIG_CONSOLE_MUX #include -#endif #endif