From patchwork Thu Aug 28 22:16:51 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 168 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=1756419466; bh=OAUKwns8Nh43xxCPBHH3Miis/ymSj4qjH+z2lIbTwEI=; 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=RRl18IW2CaCCyKtuX13a15aABuYz4GWMARMd6LufH9IfgeBuv0dMci02an4Q+SoDN P52TRILvhs0JuYppqzHudVT5kZEsCLlIs5nRlb+koKQ1T6Jt9bZW9o7QSc35mtzHGW TMT68zRCzW1otFHjXTzm8Si3MThlcJWBMzhR7vrFwpw4hH4dzldzgezmb+K/NFDH1a 30SgzODBbgXLIEB9CRBSfG80lUiEYFO284sNzrfgir/0Pg1l/33RoxrVLfTlfUDz/T fJZuO2moZGASXbLBjUReCz1lXlvAWNd6o5wf737LEEglKHyd5xkgjDwnSqkB23zxq/ 1AlzUeyfQo8Yw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8A714677FE for ; Thu, 28 Aug 2025 16:17:46 -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 dJug5n2fqZTE for ; Thu, 28 Aug 2025 16:17:46 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756419465; bh=OAUKwns8Nh43xxCPBHH3Miis/ymSj4qjH+z2lIbTwEI=; 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=G+6spO4UP9Y0THM/h3rKm9ERrbsj62Fj7bBADFITFAkmMdH+1r+j2T0lRCHRQoR8j PYGlfM3IA1osaWxd7iG04xLm3xB9nmvcAQm2o58qL0DlgJYeteY0Uzy+gkdclVgFgk kg6cuIwqtdoqPnvefVzQgCRiQCxn8keZn6cIATMJKaH+QUHDf+MGm1SG3yC8ew61R/ vYP3U2+1mv+dsbrTn1qd6qPErLTMlu87ed22wLkKIoPUOeDOYkDd9QK0ji2TMQoLB8 R25mAs2J3tI+cs5fncRbd5xkTq1IkjExWLAAJOwz1hvDfPWufO9aQxNjs8fapss87h Sk9Nq3Kfc+kBw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3C14167849 for ; Thu, 28 Aug 2025 16:17:45 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756419462; bh=bPx1BHW2Q4qmJpTf0cs9Feebp9Za2cNHbULVWTzFBWs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Iwfv9JU6uFRb4as7JkWd/FkDCIwBOhbHXt9uj72XAhDaltRn0rYAGablbBjU2cA6U g1eeJlL9IwqDiHLFG3aIkTjdNChNr/3SjH3F6rcc/uc4IsBEh0oXNJJMS5bAWB1M8g Briwhl5aVtnB9PG2GkmPqwCW6e7OGOPfar35s4gxil6O5GSymz5SJFmYuWFIO8/6F0 UkHy3lYyQhYXrl5fu2ZbtIj+rCs7J3TpKyzbFykSrQ2FsMEIUYi9bmVBECRUUxqeAy 8VKQwIJ/3UzBP/cPznryVtHRyeBh9DVTzkJXd2aIQhf21kIFJQN/KtDL4Vn9adFHXh u57ul0OCBn7Gw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 225066780C; Thu, 28 Aug 2025 16:17:42 -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 lKW15m3inDly; Thu, 28 Aug 2025 16:17:42 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756419461; bh=bGXcnmCxY/OqXubGmw9lxMT4OtPB9IlAuvX8kazI2PY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DPgR+RrIHftSLOnepmODmTD6piQnX2lXQtJI9av6oHmjVwYRHFYHShcNWgmZSAiJO 3Goaf91A4mlMkHI97h0rcd3pLXgsWn6uJ97B98h4J9DJ6GqKtr8EbuMBP2/btX5JjO jD50KDsTFI839MKLiPex/fEqHjo5H7slBGBC4P+8q882yZzxr7PQEQoZYVns1Kfq2L smObyVQ1bGlMIXZpDQY0PIOlSC7qMJoFn0k79YUyfotiyVNDxJUiEjwaVkBZUR2ZoM dsqhEDhZkjdjMfxeLg/vH345n8vp2T5GJ6aBsUtUv4cPGsR6wNyP1RnEgdJRHCPmQV XD60zTPPoTg8w== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 903F15FC79; Thu, 28 Aug 2025 16:17:41 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Thu, 28 Aug 2025 16:16:51 -0600 Message-ID: <20250828221713.3218908-6-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250828221713.3218908-1-sjg@u-boot.org> References: <20250828221713.3218908-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: CPLUDVMDF4636AVMZLH5O5Y77MH26IH2 X-Message-ID-Hash: CPLUDVMDF4636AVMZLH5O5Y77MH26IH2 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 5/8] 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. Signed-off-by: Simon Glass --- boot/bootflow.c | 27 +++++++++++++++++++++++++++ cmd/bootflow.c | 16 +--------------- include/bootflow.h | 8 ++++++++ 3 files changed, 36 insertions(+), 15 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