From patchwork Wed Jan 17 08:54:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 124794 Delivered-To: patch@linaro.org Received: by 10.46.64.148 with SMTP id r20csp1309462lje; Wed, 17 Jan 2018 00:59:43 -0800 (PST) X-Google-Smtp-Source: ACJfBovTNZnygfQysHK3e7wQy0gj3hAguZYcBa4KKTR4V8CvJlkHtMf6QKX67iLhNjG3fVvFahPM X-Received: by 10.80.138.208 with SMTP id k16mr1895641edk.181.1516179583654; Wed, 17 Jan 2018 00:59:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516179583; cv=none; d=google.com; s=arc-20160816; b=A/EygFy8FzrSplHHEPcq6XuENd5HFq23FB4DHIgHGOcjGdBUaAx8YyvOUM9A1q2Y9F BzM0ZFX62+uoQgJgp+DadmWwXvCBk/1Pbl7R83qHZnMSpgtMThnxDxjSso80cNsfcryp UUzKWA7dFz39MVX3M+79053DUTxYXEeL8Nah7eWyaJKt7rKKxaSoc4z/fT1kIWaoZ7MK X4GchMzsU2u5JckmmRsF5ZxeXgDE+Q4UPlS7KENHQh8POR6pr1zO6w7jz3SX5Ahqvsld s8t/RsnskCgfhr1B3TTsggfV/s62b2vAadeysTJIDPiwP7ExdxLG+dMyrAzJjDHw28CN tmjQ== 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:cc:references:in-reply-to:message-id :date:to:from:arc-authentication-results; bh=LKp5DLqGmpACn8zPdjaaDeVBxqRnnrIKsHyx6Pu1Qw8=; b=g8UIQtNr1hIKZ5t091LZPnQXZ6qB2c2HuTwrwWHZ55RZid06oW5D37itJqAO8dLFKi qwlww0eRgkqUoEEO+Kcm3sPBmKvjt0xY/j8PHytuVf8B1b2F/TcmOmJU6dV2e/P71u+e Gj5LlTrsPQB6qKthkGpdbJHQBx1Aeao6rHzc6lNuQQsVbG9jbT8zhruLjOuymzd6GuQy ye1Bi+EYyp+JlqFUwfDQoKmOd8H0FfUMsrml664iNxJ8sGpIUn3FvzOG2gOJufgzmuLW zmJG8umoPmncyyVRxeT4ogjppMRFyNzt5xuY77mZAyfD0hCHE/p/B4ifxgw3gjNjGVyp rcnw== 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 36si2166089edk.378.2018.01.17.00.59.43; Wed, 17 Jan 2018 00:59:43 -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 3B55CC21E18; Wed, 17 Jan 2018 08:56: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=RCVD_IN_DNSWL_BLOCKED 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 E8FF8C21E70; Wed, 17 Jan 2018 08:55:05 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 6FE02C21C50; Wed, 17 Jan 2018 08:55:00 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id A0095C21DDF for ; Wed, 17 Jan 2018 08:54:59 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 19635AEF3; Wed, 17 Jan 2018 08:54:59 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Wed, 17 Jan 2018 09:54:52 +0100 Message-Id: <20180117085458.27293-2-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180117085458.27293-1-agraf@suse.de> References: <20180117085458.27293-1-agraf@suse.de> Cc: Heinrich Schuchardt Subject: [U-Boot] [PATCH v2 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 Reviewed-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- v1 -> v2: - Make search logic easier to follow --- drivers/serial/serial-uclass.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c index 2e5116f7ce..68ca2d09d1 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,10 +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)) { - gd->cur_serial_dev = dev; - return; + !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 */ + gd->cur_serial_dev = dev; + return; + } } #undef INDEX }