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 B02B3C54EBC for ; Sun, 8 Jan 2023 03:01:58 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DC890856C9; Sun, 8 Jan 2023 03:57:02 +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="oDdusS8U"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 48F1585604; Sun, 8 Jan 2023 03:56:24 +0100 (CET) Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) (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 40D1285629 for ; Sun, 8 Jan 2023 03:51:36 +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-il1-x12b.google.com with SMTP id u8so3271490ilq.13 for ; Sat, 07 Jan 2023 18:51:36 -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=DKaYhcGfEloas46nOq3cKHkcilG587hYh1YD2kUJvhg=; b=oDdusS8UzdxzGam1SL2pZJoI4lUL6WiKq/rOj2IcQ2Qwc5d0WhUfK++cONiE8ZM3hX TH7tpM0qIl147yqO4P8YcGKYNIgJ9OqW+NJlvvkF225x6R3DSbL2bgkWuxZCBonX/5Jy J9U/NnnmLn/xcMANtG2dRg84jc9FuIde7J3Vc= 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=DKaYhcGfEloas46nOq3cKHkcilG587hYh1YD2kUJvhg=; b=Iykpm6do1nUNDmvS8oUd6v6ilsvf6SiWeKMTIdDRZ0Oh6d9UM4e7vFA5oQJrmSOe/Z Ohq+sMe+Z16FhOluRQpHpFGi3gVFAP6mGYBZCOZ/SCboUU2BYNzXQ66cbHmDSOk93QOU CL/8YS3CMPM/KFNWgR3NXxS8riXmsgKmxgAvKcDBZ6LgtKsbNe/rKyWD5ixZG1mWP5+7 FGMkAfQTpUmPl18iHxDVY10yTPLqe6Ls5MuzcRyphKI4yGLUOUOdE66PgP4DCt5ooNJ1 1u122PQFg2Aev1E91oJ3DERzeK490RM5e6UHRVzI7WsVw4LazZec6rlEx+HNTQHHAnTn xfJQ== X-Gm-Message-State: AFqh2koekiM+54tZE5FVezCTzRkL0f5jgXOHCOMzxSBUWaC57sijwj+v P5OIjy/8IsBsEjYYDTv2ihgzK2ZwU6XyeXZ9 X-Google-Smtp-Source: AMrXdXv21g8uqNLQBZP/cg12BK7IUMCOGTGq5N1sZtU+b0fljc3/7wWISmLZgk3Kj9G6dvxpEU3OXw== X-Received: by 2002:a92:ca8f:0:b0:30c:d46:de86 with SMTP id t15-20020a92ca8f000000b0030c0d46de86mr26857003ilo.26.1673146295738; Sat, 07 Jan 2023 18:51:35 -0800 (PST) Received: from sjg1.roam.corp.google.com (c-71-56-217-229.hsd1.co.comcast.net. [71.56.217.229]) by smtp.gmail.com with ESMTPSA id c17-20020a92bd11000000b00302a00aaefasm1622174ile.26.2023.01.07.18.51.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Jan 2023 18:51:35 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass Subject: [PATCH v2 58/71] bootstd: Allow hunting for bootdevs of a given priority Date: Sat, 7 Jan 2023 19:50:34 -0700 Message-Id: <20230108025047.522240-59-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20230108025047.522240-1-sjg@chromium.org> References: <20230108025047.522240-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 Add a way to run the hunter function for a particular priority, so that new bootdevs can be found. Signed-off-by: Simon Glass --- (no changes since v1) boot/bootdev-uclass.c | 25 +++++++++++++++++++++++++ include/bootdev.h | 11 +++++++++++ test/boot/bootdev.c | 25 +++++++++++++++++++++++++ 3 files changed, 61 insertions(+) diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c index 7ac42afd7b3..e8686159f2b 100644 --- a/boot/bootdev-uclass.c +++ b/boot/bootdev-uclass.c @@ -742,6 +742,31 @@ int bootdev_hunt(const char *spec, bool show) return result; } +int bootdev_hunt_prio(enum bootdev_prio_t prio, bool show) +{ + struct bootdev_hunter *start; + int n_ent, i; + int result; + + start = ll_entry_start(struct bootdev_hunter, bootdev_hunter); + n_ent = ll_entry_count(struct bootdev_hunter, bootdev_hunter); + result = 0; + + log_debug("Hunting for priority %d\n", prio); + for (i = 0; i < n_ent; i++) { + struct bootdev_hunter *info = start + i; + int ret; + + if (prio != info->prio) + continue; + ret = bootdev_hunt_drv(info, i, show); + if (ret && ret != -ENOENT) + result = ret; + } + + return result; +} + void bootdev_list_hunters(struct bootstd_priv *std) { struct bootdev_hunter *orig, *start; diff --git a/include/bootdev.h b/include/bootdev.h index db03c5c032e..b7973fa5760 100644 --- a/include/bootdev.h +++ b/include/bootdev.h @@ -284,6 +284,17 @@ void bootdev_list_hunters(struct bootstd_priv *std); */ int bootdev_hunt(const char *spec, bool show); +/** + * bootdev_hunt_prio() - Hunt for bootdevs of a particular priority + * + * This runs all hunters which can find bootdevs of the given priority. + * + * @prio: Priority to use + * @show: true to show each hunter as it is used + * Returns: 0 if OK, -ve on error + */ +int bootdev_hunt_prio(enum bootdev_prio_t prio, bool show); + #if CONFIG_IS_ENABLED(BOOTSTD) /** * bootdev_setup_for_dev() - Bind a new bootdev device (deprecated) diff --git a/test/boot/bootdev.c b/test/boot/bootdev.c index e6045b05d81..f9653633a68 100644 --- a/test/boot/bootdev.c +++ b/test/boot/bootdev.c @@ -363,3 +363,28 @@ static int bootdev_test_bootable(struct unit_test_state *uts) return 0; } BOOTSTD_TEST(bootdev_test_bootable, UT_TESTF_DM | UT_TESTF_SCAN_FDT); + +/* Check hunting for bootdev of a particular priority */ +static int bootdev_test_hunt_prio(struct unit_test_state *uts) +{ + test_set_skip_delays(true); + + console_record_reset_enable(); + ut_assertok(bootdev_hunt_prio(BOOTDEVP_2_SCAN_FAST, false)); + ut_assert_nextline("scanning bus for devices..."); + ut_assert_skip_to_line(" Type: Hard Disk"); + ut_assert_nextlinen(" Capacity:"); + ut_assert_console_end(); + + /* now try a different priority, verbosely */ + ut_assertok(bootdev_hunt_prio(BOOTDEVP_3_SCAN_SLOW, true)); + ut_assert_nextline("Hunting with: ide"); + ut_assert_nextline("Bus 0: not available "); + ut_assert_nextline("Hunting with: usb"); + ut_assert_nextline( + "Bus usb@1: scanning bus usb@1 for devices... 5 USB Device(s) found"); + ut_assert_console_end(); + + return 0; +} +BOOTSTD_TEST(bootdev_test_hunt_prio, UT_TESTF_DM | UT_TESTF_SCAN_FDT); -- 2.39.0.314.g84b9a713c41-goog