From patchwork Tue Jan 16 13:47:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 124693 Delivered-To: patch@linaro.org Received: by 10.46.64.148 with SMTP id r20csp1019987lje; Tue, 16 Jan 2018 05:49:47 -0800 (PST) X-Google-Smtp-Source: ACJfBou2Ixz66XDC2HenLl1u0OeqVKsCSY2WpkHffLHbMlQVZ1tvvRe2Y4IKIzWftYf4sExtSnaV X-Received: by 10.80.167.101 with SMTP id h92mr52911992edc.202.1516110587245; Tue, 16 Jan 2018 05:49:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516110587; cv=none; d=google.com; s=arc-20160816; b=GbYyMsBykRv7QLEZZRpuoTF5vnnpq0n3+CO0djTLfySSe9UCAAgW9BgcA7gTQDapQO k3e9tnuzO7sU5D+Xd4JTMUZA8C6r6Wm7/FgFZMSV+hPiYyC0Wr6RQ+QS5w4Zu+br1kxl RbfOP1n2JAcmE9Vj8soH+UfNJn/kJpMuHu+BDmjvH6+vgG6xJncZl5R37DZ+5EPP/Etu phbpev2G0mMfoHhSFu1AE3fNwwUNcLL+3j/k5GeQ7aUlKbG4Bogt06qhRlfsz2i+ly0i W9PaMfw6iBR8I/JkhweaqiAiWuXHENPD1dlKmmbjkXKjyXzz/X7JOzhDSChM7x0ExHQF j4+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:arc-authentication-results; bh=ufvIM3QBRA05ppCL0whjQfYHHlVYBz8TyGlWDIcClLw=; b=JeHv6kF822sEW5jR/ytrepkxgo06AS/aGxZhkYdr0FhDRV4TQ6j7xA0edHAG8ouuQx iqxxqLEMzQT1IBVQWeepWOoR7zXW0tdVvxYghJLmmSTqma+pqFuB0MP3jh8+m3P38gIF MAUBBiYXtxLZU1iMzNC8sL6lwGisJ4su7GFyeBFtNJHYrOt10eErWJGh2kmTPuLpfnzE QKB+2FZ7W1J/p2e2vTjlOBdDeklR3auOyZ+3yBXYAW1Oo7t0kHjg7Ux3dCbuvsbgIPf3 7xZcAUR4LDS/6dzvKsfkob8IHWlEVzazuE/1mw3RU0Urw2EhnKMoNjO+h3tWz4F2+7eH zsOQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id w50si2229958eda.81.2018.01.16.05.49.46; Tue, 16 Jan 2018 05:49:47 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id C1CF4C21E0E; Tue, 16 Jan 2018 13:49:16 +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=none 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 A5E7EC21DF3; Tue, 16 Jan 2018 13:48:41 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 89639C21E0A; Tue, 16 Jan 2018 13:47:56 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id 743BFC21E48 for ; Tue, 16 Jan 2018 13:47:42 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 3E33FAD02; Tue, 16 Jan 2018 13:47:42 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Tue, 16 Jan 2018 14:47:35 +0100 Message-Id: <20180116134741.4103-2-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180116134741.4103-1-agraf@suse.de> References: <20180116134741.4103-1-agraf@suse.de> Subject: [U-Boot] [PATCH 1/7] serial: Use next serial device if probing fails 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" Currently our serial device search chokes on the fact that the serial probe function could fail. If it does, instead of searching for the next usable serial device, it just quits. This patch changes the fallback logic so that even when a serial device was not probed correctly, we just try the next ones until we find one that works. Signed-off-by: Alexander Graf --- drivers/serial/serial-uclass.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c index 2e5116f7ce..637544d1a7 100644 --- a/drivers/serial/serial-uclass.c +++ b/drivers/serial/serial-uclass.c @@ -74,6 +74,7 @@ static void serial_find_console_or_panic(void) { const void *blob = gd->fdt_blob; struct udevice *dev; + int ret; if (CONFIG_IS_ENABLED(OF_PLATDATA)) { uclass_first_device(UCLASS_SERIAL, &dev); @@ -104,8 +105,8 @@ static void serial_find_console_or_panic(void) * from 1!). * * Failing that, get the device with sequence number 0, or in - * extremis just the first serial device we can find. But we - * insist on having a console (even if it is silent). + * extremis just the first working serial device we can find. + * But we insist on having a console (even if it is silent). */ #ifdef CONFIG_CONS_INDEX #define INDEX (CONFIG_CONS_INDEX - 1) @@ -113,8 +114,22 @@ static void serial_find_console_or_panic(void) #define INDEX 0 #endif if (!uclass_get_device_by_seq(UCLASS_SERIAL, INDEX, &dev) || - !uclass_get_device(UCLASS_SERIAL, INDEX, &dev) || - (!uclass_first_device(UCLASS_SERIAL, &dev) && dev)) { + !uclass_get_device(UCLASS_SERIAL, INDEX, &dev)) { + if (dev->flags & DM_FLAG_ACTIVATED) { + gd->cur_serial_dev = dev; + return; + } + } + + /* Search for any working device */ + for (ret = uclass_first_device_check(UCLASS_SERIAL, &dev); + dev; + ret = uclass_next_device_check(&dev)) { + if (ret) { + /* Device did succeed probing */ + continue; + } + gd->cur_serial_dev = dev; return; }