From patchwork Tue Sep 2 15:21:39 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 177 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756826549; bh=lQoBuoUyWt1IpdzAAnGhrlJyJ++SDFPIOu6kTo220VQ=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=u5n9SoWqTyMsZkuyd+2v7p/dYEVOdvA0XZRxs1XELoeFti9sgeG+lmPLO7YsULRYD BKNAe0YT2jM0R27NA0FlhseZ1lDULv9LhT+bPi5ySdRRVsACCe9c1W5PNpm87PPIRP Pv12Jaz+1hpLeSHEI58jCU4pvifwjcCOhwYxlxtuK4++sNGkpGlaqpxlLdKWP93SYQ TgbpMHRwQ2lvo+0af79545MjG+dSsdAcf9JP36dMACfgRHV5KxjXtea5soM6vk2O/r 0FpfMSgM9ECdIbATkVakSpk6yf2aSmNSttJT5YIsHxSNs2WHh/kRxgUm6OgJ5BRgqd tPLH2BSWgagew== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id BE724678B0 for ; Tue, 2 Sep 2025 09:22:29 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 5Wv2kFI8dsIi for ; Tue, 2 Sep 2025 09:22:29 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756826549; bh=lQoBuoUyWt1IpdzAAnGhrlJyJ++SDFPIOu6kTo220VQ=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=u5n9SoWqTyMsZkuyd+2v7p/dYEVOdvA0XZRxs1XELoeFti9sgeG+lmPLO7YsULRYD BKNAe0YT2jM0R27NA0FlhseZ1lDULv9LhT+bPi5ySdRRVsACCe9c1W5PNpm87PPIRP Pv12Jaz+1hpLeSHEI58jCU4pvifwjcCOhwYxlxtuK4++sNGkpGlaqpxlLdKWP93SYQ TgbpMHRwQ2lvo+0af79545MjG+dSsdAcf9JP36dMACfgRHV5KxjXtea5soM6vk2O/r 0FpfMSgM9ECdIbATkVakSpk6yf2aSmNSttJT5YIsHxSNs2WHh/kRxgUm6OgJ5BRgqd tPLH2BSWgagew== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id AC4B65FE1B for ; Tue, 2 Sep 2025 09:22:29 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756826547; bh=NhoDKAIBM0DZGTZy5qEzbwUd74atBNr2GbAt0LYwwS8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MeKd+6w0ksPQeCq+ToLtIZL6XJzSOJbMBbsomhBol2RVnvAEMoJQDjfkDVLMxf3Df t9sYf4Fqv9mo5PU84/xlhOlXARYX1AdjOQyrsck/9zF8ImtLlXw+0DDPktKOoEfJtt 174ErTkKVI6jx3t048ejwcvHnjoScdkGIo8uOTwYKASp00JGXDLzvpwKMh2t3y6fpT nV0PG/8AnSBtqWsVdDkiZkvaNKSx5OracFQA9S85P5zOaLNH8XNqBmn/7cpehKbbnF zsBdO7OqxgnyIDTcTXrkvTu3bCuOjZMis8//kPQebCwlrNaLsTGAVraSAd6RXzXRn6 eXRusLX8kNRiQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A168D678B0; Tue, 2 Sep 2025 09:22:27 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id vFlATmvV9Wij; Tue, 2 Sep 2025 09:22:27 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756826544; bh=botqfGuJrgX9J0c6KEwxStfn69CRLSyx8HKXy1mz83U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nu9M4lVecJ/cDgL6kmfmAJApGEEi4UbvoQB4k8E+9yN/GBjT2w48Z7850Agqlnahs 1XMGXJ5y3MYqWA9DEoQbcS8zbAAh93JUPPwmdsXaO4zz2tOoWNv6SrVLeOtJNWOYoh s9NDz7zK8zoQbh1HfzxM+bWctW374s9jUkJPjm3s5296e9NBOIj2doY4XCKeq2Ht/7 3Dg3i5DiObemUdeOE959L8mjj470If8tQNjGBEeBmeyiAtt3XHUR0xPhCCzXna1rwg ClZ5g+vJJwoPeHcpyLCpPw036kAZLpQ3lYwoxDGnRsl3oyC9dq8MMB5CHn5KGtKsYO julg+t7tT7IcA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 6C488678E8; Tue, 2 Sep 2025 09:22:24 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 2 Sep 2025 09:21:39 -0600 Message-ID: <20250902152158.2285264-8-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250902152158.2285264-1-sjg@u-boot.org> References: <20250902152158.2285264-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: LUFHN7AN43DRTEWD6TU7FTODJJCZ5BSB X-Message-ID-Hash: LUFHN7AN43DRTEWD6TU7FTODJJCZ5BSB X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 07/18] boot: Move obtaining the label into a common file List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass The 'bootflow list' command supports looking at the EFI device-path when available. Move this piece into a common function so it can be used elsewhere. This updates the output from 'bootflow list'. Signed-off-by: Simon Glass --- boot/bootflow.c | 27 +++++++++++++++++++++++++++ cmd/bootflow.c | 16 +--------------- include/bootflow.h | 8 ++++++++ test/boot/bootflow.c | 4 ++-- 4 files changed, 38 insertions(+), 17 deletions(-) diff --git a/boot/bootflow.c b/boot/bootflow.c index c088300ea96..c8391641001 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -1024,3 +1025,29 @@ int bootflow_get_seq(const struct bootflow *bflow) return alist_calc_index(&std->bootflows, bflow); } + +const char *bootflow_guess_label(const struct bootflow *bflow) +{ + const char *name = NULL; + + if (IS_ENABLED(CONFIG_EFI_APP)) { + struct efi_device_path *dp; + enum uclass_id id; + int ret; + + ret = efi_dp_from_bootflow(bflow, &dp, NULL); + if (!ret) + name = efi_dp_guess_uclass(dp, &id); + } else if (bflow->dev) { + struct udevice *media = dev_get_parent(bflow->dev); + + if (device_get_uclass_id(media) == UCLASS_MASS_STORAGE) + name = "usb"; + else + name = dev_get_uclass_name(media); + } + if (!name) + name = "(none)"; + + return name; +} diff --git a/cmd/bootflow.c b/cmd/bootflow.c index 20fc04bdda3..43335fecb34 100644 --- a/cmd/bootflow.c +++ b/cmd/bootflow.c @@ -70,21 +70,7 @@ static void report_bootflow_err(struct bootflow *bflow, int err) */ static void show_bootflow(int index, struct bootflow *bflow, bool errors) { - const char *name = NULL; - - if (IS_ENABLED(CONFIG_EFI_APP)) { - struct efi_device_path *dp; - enum uclass_id id; - int ret; - - ret = efi_dp_from_bootflow(bflow, &dp, NULL); - if (!ret) - name = efi_dp_guess_uclass(dp, &id); - } else if (bflow->dev) { - name = dev_get_uclass_name(dev_get_parent(bflow->dev)); - } - if (!name) - name = "(none)"; + const char *name = bootflow_guess_label(bflow); printf("%3x %-11s %-6s %-9.9s %4x %-25.25s %s\n", index, bflow->method ? bflow->method->name : "(none)", diff --git a/include/bootflow.h b/include/bootflow.h index ec5baff7e01..422fd32a3ca 100644 --- a/include/bootflow.h +++ b/include/bootflow.h @@ -725,4 +725,12 @@ int bootflow_menu_start(struct bootstd_priv *std, bool text_mode, */ int bootflow_menu_poll(struct expo *exp, int *seqp); +/** + * bootflow_guess_label() - Produce a plausible label for a bootflow + * + * This uses the uclass name or EFI device-path to come up with a useful label + * for display to the user. Ideally it will say "mmc", "usb", nvme", etc. + */ +const char *bootflow_guess_label(const struct bootflow *bflow); + #endif diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c index 620af312700..14e3326a08f 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -1349,9 +1349,9 @@ static int bootflow_efi(struct unit_test_state *uts) ut_assert_nextlinen("---"); ut_assert_nextlinen(" 0 extlinux"); ut_assert_nextlinen( - " 1 efi ready usb_mass_ 1 hub1.p2.usb_mass_storage. /EFI/BOOT/BOOTSBOX.EFI"); + " 1 efi ready usb 1 hub1.p2.usb_mass_storage. /EFI/BOOT/BOOTSBOX.EFI"); ut_assert_nextlinen( - " 2 extlinux ready usb_mass_ 1 hub1.p4.usb_mass_storage. /extlinux/extlinux.conf"); + " 2 extlinux ready usb 1 hub1.p4.usb_mass_storage. /extlinux/extlinux.conf"); ut_assert_nextlinen("---"); ut_assert_skip_to_line("(3 bootflows, 3 valid)"); ut_assert_console_end();