From patchwork Wed Sep 27 01:19:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 818881 X-Patchwork-Delegate: trini@ti.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="jpKLkw67"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3y20Nq2SWFz9t2Q for ; Wed, 27 Sep 2017 11:19:54 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 9ABF6C21D99; Wed, 27 Sep 2017 01:19:51 +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 1E13DC21C40; Wed, 27 Sep 2017 01:19:48 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 9D2C9C21C40; Wed, 27 Sep 2017 01:19:45 +0000 (UTC) Received: from mail-qk0-f196.google.com (mail-qk0-f196.google.com [209.85.220.196]) by lists.denx.de (Postfix) with ESMTPS id 1A173C21C26 for ; Wed, 27 Sep 2017 01:19:45 +0000 (UTC) Received: by mail-qk0-f196.google.com with SMTP id r66so7891401qke.4 for ; Tue, 26 Sep 2017 18:19:45 -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=NVJKP+RY4Z5ROu67hykBXbKdgN19vRl3LI4ijjxXPzI=; b=jpKLkw67hC1+vxD8uoelpD4RwJgmFsY54ckGwqtwHZwMs0cOwgVngDzXG7HJ0G8M+/ nUDlC1W4nySru85w7SAPvJI8fd6+XvscXWGt57WJKwT+gLYrHTHQcmweP53B2TQoRxIh QC/W6hWlOFDwX+BPsmkd0UDTt2pPqFHwwGyl5WtKm1i2orBS0DWfgGhi77KOBkW9SdPP ZZu0G7+fSdFgRCtE2CKkJHcnegjipVY4qi4T7mWo1BBbay+e6y5hh7DPN+IW4Y7Btqdn 5Ga1BoBjUl/AvaBxPJnVfmfZvqd+hg6h+9HJq0KYQB7Ga/gHl8lwuDKX61AT9z8200dy kaKA== 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=NVJKP+RY4Z5ROu67hykBXbKdgN19vRl3LI4ijjxXPzI=; b=L1+QuWLDxMRt58CbvtRNOKIImyiXqabp2p0aJj2065zIhx1HMxtE6yYdFJoBjUJjEx CzbJYX316xwaGbTswqQB8Z2H0mCn2acdeovn36jp9AEJUAj9DMn8RufajB/4v3N1jOza 2bkHktYF3dsknU93i8oYztes/NEPDQSVY8Pq3zyupH0TV3hMjN78r7X1bsqWFfrWfjVO IUld7SC27z5YeIkY0CsyY4SanEg4Slin7xtsv/3ADCNL+XmNJDHhaJVEuHVyKEROQoFW CPL7fuZ6f4eheVXy/4Nxfz6ep7+HlsxQNl3XdUchtZu8tPYSSrbJiuP7EPKqG0BvWAyd 8nXQ== X-Gm-Message-State: AMCzsaVmYmh76uVymNhhDgGaaQdN4FVEZ22lq9pQFI6XROylvyyN4nf8 +x/Tu24h7RP62Qqbi8uMcaE2A6ye X-Google-Smtp-Source: AOwi7QCq2f3MnbAM1zfw6xOYV85YPq5sfrgOqxWd2ENPCqc29gaKaTbD9O2Kn+8a4a712gC5d7VW6A== X-Received: by 10.55.98.19 with SMTP id w19mr285674qkb.261.1506475183286; Tue, 26 Sep 2017 18:19:43 -0700 (PDT) Received: from localhost (h3.248.139.40.ip.windstream.net. [40.139.248.3]) by smtp.gmail.com with ESMTPSA id z195sm7766610qkz.42.2017.09.26.18.19.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Sep 2017 18:19:42 -0700 (PDT) From: Rob Clark To: U-Boot Mailing List Date: Tue, 26 Sep 2017 21:19:37 -0400 Message-Id: <20170927011939.6610-1-robdclark@gmail.com> X-Mailer: git-send-email 2.13.5 Subject: [U-Boot] [PATCH] 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 Tested-by: Peter Robinson Reviewed-by: Bin Meng Reviewed-by: Simon Glass --- Somehow this patch was dropped on the floor. I don't remember which version # this is up to, search the list if you care. But this is the latest. I only noticed it was missing because u-boot crashes when you boot with usb-keyboard plugged in (at least on db410c) without it. So someone please apply this patch before it gets lost again. 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 a323d72a36..4c3ad95fca 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 = env_get("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