From patchwork Thu Nov 20 02:56:01 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 754 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=1763607463; bh=MQD80w2rPNBq3L8UK5qFf5TrjTIFR22HhKBgeBe2A7E=; 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=dOCpK8i1eAyecC3mqlbgxOoEpzEXiWgAm73gQpUGngktnUMkz2ZX5gIRNja3fqQXC SSXbN0/lX7i68MIqPatjwhHOxxYH1lzYa5ZmENiUXl/CShMOBqwL6+nbDUcdRQpdfu 5air95FAtGHymydt2ftUBR6N5ET7UQxmP+71cpDDevUfADRV2q6z3yr9JCM3zTwulW cdhzUksRxrBPc4W6aCEQFSiKA6W8NJY/EaJDW4HSqMLy/QrzN8NyHY4ySBiKlCu3xs pefpPNUu9Yu5FRwfqKqSLO7IfYmXOaA6M4x/frxXERp0YLRFV0LXKb7ddPRMD5PLwH 0GBIPjE9KKVJA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id AE7FB686D8 for ; Wed, 19 Nov 2025 19:57:43 -0700 (MST) 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 cgtJR91Xum4F for ; Wed, 19 Nov 2025 19:57:43 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607463; bh=MQD80w2rPNBq3L8UK5qFf5TrjTIFR22HhKBgeBe2A7E=; 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=dOCpK8i1eAyecC3mqlbgxOoEpzEXiWgAm73gQpUGngktnUMkz2ZX5gIRNja3fqQXC SSXbN0/lX7i68MIqPatjwhHOxxYH1lzYa5ZmENiUXl/CShMOBqwL6+nbDUcdRQpdfu 5air95FAtGHymydt2ftUBR6N5ET7UQxmP+71cpDDevUfADRV2q6z3yr9JCM3zTwulW cdhzUksRxrBPc4W6aCEQFSiKA6W8NJY/EaJDW4HSqMLy/QrzN8NyHY4ySBiKlCu3xs pefpPNUu9Yu5FRwfqKqSLO7IfYmXOaA6M4x/frxXERp0YLRFV0LXKb7ddPRMD5PLwH 0GBIPjE9KKVJA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9DAFB68657 for ; Wed, 19 Nov 2025 19:57:43 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607461; bh=0jllZ0zGeIWHvJI8UOpX6HMZfzbABlNOs2lNihStdMk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ExH7KJds1pXYYsUv1dp73V98EiSIxWJvULyB/kv8dDF4PUX4YgDEt8zzUwxtU8QvN OpO68y9F2i8FZreE+SuoBaeWZwBmMLkbrATeZG2qIroEUJcwgKHiqcKxFPvhJAu8uY aLO7VnoB2nHIwrZFm547OvsyQHt/vH3pSRn2HAktYo4ArpFe44zPfBSZ9fe4xK6Yxg t7bpx0zmul0Ft2zfyM3rg2mG3syqHDHY45ypshrA7jXv130JBM1DBLyCSx2KBvGLCg emA0n5Bvi9zAn66cG0lpfk8l9cpoM1N/zISW2FzXY8DhQ095QZV/MiLYk5zYn15CfC QeNDTt/Ch06wA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8D616686D8; Wed, 19 Nov 2025 19:57:41 -0700 (MST) 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 QF3hfmbah1LU; Wed, 19 Nov 2025 19:57:41 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607456; bh=XQUqp/c7SgJFlWVJO4XHj8UUqTcBREsO7OktQvGAmf4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DkrnWm7XpcOCd1Ect/03Cn6Jrem01VuBTIkqOLbCDHFvh9gZYlnJzuLzsYu0kLkxz n8WIIqn2Zwj6PKECHuekiPuWkMAnTvdTaS1oOMnMSeoiPDpWZ2T6DihER7MFviG+VX 5X0hjdi+Ki9CEeDURfylROHXQIRbNAhv1kiD5JM9fPJVQ14ULoD4PkZElX8s2UJ93i YK+2kqdMGLeO3nbuxTPJrq+gCEe54yPDXOR2t1WesNqViXWkAWVdOdkwpmQ/3MESEO LnkykJ3ZQERevmJKnWbJRhbTv21Y+0FVEqN/Et8eizff4klO228ixlANOvKJZet7oy AZ3SfqSjj4ATw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id C4DC268657; Wed, 19 Nov 2025 19:57:35 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 19 Nov 2025 19:56:01 -0700 Message-ID: <20251120025614.2215587-27-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251120025614.2215587-1-sjg@u-boot.org> References: <20251120025614.2215587-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: DGBXTD6QW6QUQDVS7MITYZ6AZAO22K56 X-Message-ID-Hash: DGBXTD6QW6QUQDVS7MITYZ6AZAO22K56 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 , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 26/30] fit: Add a helper for printing descriptions 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 Add emit_desc() which handles getting and printing descriptions from FIT nodes. Handle the "unavailable" case when a description is missing. Co-developed-by: Claude Signed-off-by: Simon Glass --- boot/fit_print.c | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/boot/fit_print.c b/boot/fit_print.c index 8781d5a7da7..069afbe8567 100644 --- a/boot/fit_print.c +++ b/boot/fit_print.c @@ -159,6 +159,26 @@ static void emit_stringlist(struct fit_print_ctx *ctx, int noffset, emit_label_val(ctx, i ? "" : label, val); } +/** + * emit_desc() - print a description + * @ctx: pointer to FIT print context + * @noffset: offset of the node containing the description + * @label: label string to use when printing + * + * Gets the description from the specified node and prints it with the given + * label. If the description is not available, prints "unavailable" instead. + * This is a convenience function for printing FIT descriptions. + */ +static void emit_desc(struct fit_print_ctx *ctx, int noffset, + const char *label) +{ + const char *desc; + int ret; + + ret = fit_get_desc(ctx->fit, noffset, &desc); + emit_label_val(ctx, label, ret ? "unavailable" : desc); +} + /** * fit_image_print_data() - prints out the hash node details * @ctx: pointer to FIT print context @@ -262,7 +282,6 @@ void fit_image_print(struct fit_print_ctx *ctx, int image_noffset) { const void *fit = ctx->fit; uint8_t type, arch, os, comp = IH_COMP_NONE; - const char *desc; size_t size; ulong load, entry; const void *data; @@ -271,8 +290,7 @@ void fit_image_print(struct fit_print_ctx *ctx, int image_noffset) int ret; /* Mandatory properties */ - ret = fit_get_desc(fit, image_noffset, &desc); - emit_label_val(ctx, "Description", ret ? "unavailable" : desc); + emit_desc(ctx, image_noffset, "Description"); emit_timestamp(ctx, 0, "Created"); @@ -368,12 +386,11 @@ void fit_image_print(struct fit_print_ctx *ctx, int image_noffset) static void fit_conf_print(struct fit_print_ctx *ctx, int noffset) { const void *fit = ctx->fit; - const char *uname, *desc; - int ret, ndepth; + const char *uname; + int ndepth; /* Mandatory properties */ - ret = fit_get_desc(fit, noffset, &desc); - emit_label_val(ctx, "Description", ret ? "unavailable" : desc); + emit_desc(ctx, noffset, "Description"); uname = fdt_getprop(fit, noffset, FIT_KERNEL_PROP, NULL); emit_label_val(ctx, "Kernel", uname ?: "unavailable"); @@ -401,18 +418,15 @@ void fit_print(struct fit_print_ctx *ctx) { const void *fit = ctx->fit; int p = ctx->indent; - const char *desc; char *uname; int images_noffset; int confs_noffset; int noffset; int ndepth; int count = 0; - int ret; /* Root node properties */ - ret = fit_get_desc(fit, 0, &desc); - emit_label_val(ctx, "FIT description", ret ? "unavailable" : desc); + emit_desc(ctx, 0, "FIT description"); emit_timestamp(ctx, 0, "Created");