Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 22814C352A1 for ; Wed, 7 Dec 2022 08:55:13 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id EEDEF85442; Wed, 7 Dec 2022 09:54:12 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="iNeKiV/O"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 967E485442; Wed, 7 Dec 2022 09:54:11 +0100 (CET) Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 963F58556A for ; Wed, 7 Dec 2022 09:54:07 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-pg1-x52e.google.com with SMTP id v3so15690166pgh.4 for ; Wed, 07 Dec 2022 00:54:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=o5VFG3nkPILUiX0sGrQFCPBzVuOQ44EsqKz12Eyzhj4=; b=iNeKiV/OyAUdYZqZZjiNrLk5sOpReXtqHVtvcm/Qlfg31D/hLTsHgixHWKhJslOPNM VZUOT9FOlx/1SDz5NxEcQtx5/LZxUe3HYrpBqnWB8/E4Dm0w/gcVS3jbuiq57FR7TnvS fyTSIkjDSp1eS1HJIINhFqGYxo4qOzDjwzVuI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=o5VFG3nkPILUiX0sGrQFCPBzVuOQ44EsqKz12Eyzhj4=; b=TwBWLU7tGAhKFTr6FV0jwF5YFkz2iurLLJlz51kX8qkM3Gtlt+EVTaGpX0GOtcZvfp if4XlZv2rVjBXAfDgTXw7iCR5iVsJ4yBY5xnwAraPqTWQ7P9ennVnlzzdp7AQAzunzbr yfGcK5mDKUs2kGv9tmhPNw+fdQTuspK9v4I/Z5gRTaFcMSTx1D3Ycvp74xYdIzJIu4fe C0yBTT9lPqx0WQIOraD1Zx7mAct4uy1Q1mgXeY/1Uvg538ZPlSE7KfnGQABjAaSF/kLd 2J/xk0V/IfIezf52xMfZon0ZbLbaqwWDxVakAMKqeUun0MHBiaLxEhXLMqNdrf6/+juw 6p8g== X-Gm-Message-State: ANoB5pnqJmnI8l5YzV90JwIqGouI5M+3CKkdrhJDftL7qgwMi7BBy0hy mUdWk2zA9PbsYgR0tK3ESp6f5H0m6dbBiIa6 X-Google-Smtp-Source: AA0mqf7GyEAa230DqO/7Fx/F9efqjhPaprh6ERNfuT0acsT+bTeeU8p+hEyAxYUeTBY+flnkvovy1g== X-Received: by 2002:aa7:9911:0:b0:576:796e:8128 with SMTP id z17-20020aa79911000000b00576796e8128mr22115583pff.68.1670403245683; Wed, 07 Dec 2022 00:54:05 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.54.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:54:05 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass Subject: [PATCH 06/71] bootstd: Simplify locating existing bootdevs Date: Wed, 7 Dec 2022 21:50:32 +1300 Message-Id: <20221207085137.445249-7-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean There is no point in trying to match the alias order for bootdevs, since build_order() either sorts them by priority, uses the boot_targets environment variable or the bootdev-order property. Just use the iterator instead, to simplify the code. Signed-off-by: Simon Glass --- boot/bootdev-uclass.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c index 696efb4b19e..cffa01824c0 100644 --- a/boot/bootdev-uclass.c +++ b/boot/bootdev-uclass.c @@ -544,8 +544,8 @@ static int build_order(struct udevice *bootstd, struct udevice **order, int bootdev_setup_iter_order(struct bootflow_iter *iter, struct udevice **devp) { struct udevice *bootstd, *dev = *devp, **order; - int upto, i; - int count; + struct uclass *uc; + int count, upto; int ret; ret = uclass_first_device_err(UCLASS_BOOTSTD, &bootstd); @@ -568,15 +568,9 @@ int bootdev_setup_iter_order(struct bootflow_iter *iter, struct udevice **devp) if (!order) return log_msg_ret("order", -ENOMEM); - /* - * Get a list of bootdevs, in seq order (i.e. using aliases). There may - * be gaps so try to count up high enough to find them all. - */ - for (i = 0, upto = 0; upto < count && i < 20 + count * 2; i++) { - ret = uclass_find_device_by_seq(UCLASS_BOOTDEV, i, &dev); - if (!ret) - order[upto++] = dev; - } + /* Get the list of bootdevs */ + uclass_id_foreach_dev(UCLASS_BOOTDEV, dev, uc) + order[upto++] = dev; log_debug("Found %d bootdevs\n", count); if (upto != count) log_debug("Expected %d bootdevs, found %d using aliases\n", -- 2.39.0.rc0.267.gcb52ba06e7-goog