From patchwork Thu Nov 20 02:56:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 753 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=1763607459; bh=gMVLLPGHFCqZOzgab3hCQAgK0SGswSi13YrL8cE7Inw=; 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=Z/8+bOE/h2reOLW0TyIGunKUt7YAftBSp9eQNKcG1v0zPrj8qwHjw6BA+GJA/U0Lb N9glLqFdLYGOLdmmLfLHZnZqze8+x9hcDue422NcEJs9icWBDF5JXo1FeMiRpojKez NCiVEmKQUFjEFkoL8O51joWUrzhC9uQk3zflzD18EoGC7Qo6q4rRlC7yjHAlIHwCax +PZl96Vo1ui+hswEza6cbqlyUJut3eMEzxAErAImH0TPxC1x1gNdubFil4CUXJrWUY uM5yeucbJdp8OLO9iiNNZJi045+YTiQb5NhC9ydoUapr5M+Qg1kJ+pz8k59Fq7LQum LopUA5JeiAVCw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 319785E7DA for ; Wed, 19 Nov 2025 19:57:39 -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 PK04A0zHOlNP for ; Wed, 19 Nov 2025 19:57:39 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607459; bh=gMVLLPGHFCqZOzgab3hCQAgK0SGswSi13YrL8cE7Inw=; 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=Z/8+bOE/h2reOLW0TyIGunKUt7YAftBSp9eQNKcG1v0zPrj8qwHjw6BA+GJA/U0Lb N9glLqFdLYGOLdmmLfLHZnZqze8+x9hcDue422NcEJs9icWBDF5JXo1FeMiRpojKez NCiVEmKQUFjEFkoL8O51joWUrzhC9uQk3zflzD18EoGC7Qo6q4rRlC7yjHAlIHwCax +PZl96Vo1ui+hswEza6cbqlyUJut3eMEzxAErAImH0TPxC1x1gNdubFil4CUXJrWUY uM5yeucbJdp8OLO9iiNNZJi045+YTiQb5NhC9ydoUapr5M+Qg1kJ+pz8k59Fq7LQum LopUA5JeiAVCw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1E9AA68631 for ; Wed, 19 Nov 2025 19:57:39 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607456; bh=pRsND2GqD4siVSe8io4n7rr9tj7S0KQefS483OVUj20=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bo6hIPB18TpLufd7DIj9vxqF20NMfu8Qj+YCoWemt/NVFG5Lpj4hlWJ8eHTC8/pPo 5g0bfthdkUD3FxZWbC50Fwk3He8voEBaIB1vEkjTTD7Hyc0V8yAu0aW6k7LA5Q+qsu Lqa/kfoK1W4g9QmKo/vAtHF1yN5tAZ4N1ENXenDHDBePKZSs3b2AVpja39hyqDLBT7 Hofgw3xzPbyHGiUuDANe2lc+5rB1rYK2wQ77LFy4whwQiHoNfnb464o7lQw7YJs9oi UwaN/nlbGyj9vfk0cw2wsOwRwNrD/kfJerfjqvcZ/tJfraAJ/9JuKUb6rm7xVR6Iny 7m4+4VM7Ln6Kg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B29B7686E6; Wed, 19 Nov 2025 19:57:36 -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 CnJc-rmoHdMy; Wed, 19 Nov 2025 19:57:36 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607451; bh=Aaz1GLFqrtUSdXf1kgrlZ2BJuD6c6aznYoNIUuZdvyI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UUjoCgqm0HuWkAUevHag7uZtFQNwpvwyxgG2yBw6g6kHMMbHGFT2ivVtqO+OLgQY7 owD/mzNftzfZ4gyeSts71XIp176g1rLB1tP4XnF8LwXOFlBy84MXKmUYqweg7N20qh rixeR7Pr2pEpaUgoEutjla+DwnESVQSyiSXgX9TI5+aCKI1mStdtgU4NAgOGxenISD giMsCY3KiFAzsDpWO/Vwvp7KoZW7ij+b0K435hu1Ru6PJyfHT6F+dO6ZoxwJ/0UmHO ceBmzqAmWR6rpupNOukQthLKh4oZ0oDb6RbpLc4ZGLYKsxSnUjcAQ1hFnBNeTCmC6N phuhyZTZpRmOQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 2684D68614; Wed, 19 Nov 2025 19:57:31 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 19 Nov 2025 19:56:00 -0700 Message-ID: <20251120025614.2215587-26-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: IH2FTV6W5AUQQZP5NZ2JEUR4IDNPOWF2 X-Message-ID-Hash: IH2FTV6W5AUQQZP5NZ2JEUR4IDNPOWF2 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 25/30] fit: Add a helper for stringlist properties 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 a emit_stringlist() helper function to simplify printing stringlist properties in FIT configurations. Co-developed-by: Claude Signed-off-by: Simon Glass --- boot/fit_print.c | 56 +++++++++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/boot/fit_print.c b/boot/fit_print.c index 9696679762d..8781d5a7da7 100644 --- a/boot/fit_print.c +++ b/boot/fit_print.c @@ -126,6 +126,8 @@ static void emit_timestamp(struct fit_print_ctx *ctx, int noffset, { time_t timestamp; + if (!IMAGE_ENABLE_TIMESTAMP) + return; emit_label(ctx, label); if (fit_get_timestamp(ctx->fit, noffset, ×tamp)) printf("unavailable\n"); @@ -133,6 +135,30 @@ static void emit_timestamp(struct fit_print_ctx *ctx, int noffset, genimg_print_time(timestamp); } +/** + * emit_stringlist() - print a stringlist property + * @ctx: pointer to FIT print context + * @noffset: offset of the node containing the property + * @prop: property name to get and print + * @label: label string to use when printing + * + * Gets a stringlist property from the specified node and prints each string + * with the given label. The first string shows the label, subsequent strings + * are indented to align with the first value. If the property doesn't exist, + * nothing is printed. + */ +static void emit_stringlist(struct fit_print_ctx *ctx, int noffset, + const char *prop, const char *label) +{ + const char *val; + int i; + + for (i = 0; + val = fdt_stringlist_get(ctx->fit, noffset, prop, i, NULL), val; + i++) + emit_label_val(ctx, i ? "" : label, val); +} + /** * fit_image_print_data() - prints out the hash node details * @ctx: pointer to FIT print context @@ -248,8 +274,7 @@ void fit_image_print(struct fit_print_ctx *ctx, int image_noffset) ret = fit_get_desc(fit, image_noffset, &desc); emit_label_val(ctx, "Description", ret ? "unavailable" : desc); - if (IMAGE_ENABLE_TIMESTAMP) - emit_timestamp(ctx, 0, "Created"); + emit_timestamp(ctx, 0, "Created"); fit_image_get_type(fit, image_noffset, &type); emit_label_val(ctx, "Type", genimg_get_type_name(type)); @@ -344,7 +369,7 @@ static void fit_conf_print(struct fit_print_ctx *ctx, int noffset) { const void *fit = ctx->fit; const char *uname, *desc; - int ret, ndepth, i; + int ret, ndepth; /* Mandatory properties */ ret = fit_get_desc(fit, noffset, &desc); @@ -356,26 +381,10 @@ static void fit_conf_print(struct fit_print_ctx *ctx, int noffset) /* Optional properties */ emit_prop(ctx, noffset, FIT_RAMDISK_PROP, "Init Ramdisk"); emit_prop(ctx, noffset, FIT_FIRMWARE_PROP, "Firmware"); - - for (i = 0; - uname = fdt_stringlist_get(fit, noffset, FIT_FDT_PROP, - i, NULL), uname; - i++) - emit_label_val(ctx, i ? "" : "FDT", uname); - + emit_stringlist(ctx, noffset, FIT_FDT_PROP, "FDT"); emit_prop(ctx, noffset, FIT_FPGA_PROP, "FPGA"); - - /* Print out all of the specified loadables */ - for (i = 0; - uname = fdt_stringlist_get(fit, noffset, FIT_LOADABLE_PROP, - i, NULL), uname; - i++) - emit_label_val(ctx, i ? "" : "Loadables", uname); - - /* Show the list of compatible strings */ - for (i = 0; uname = fdt_stringlist_get(fit, noffset, - FIT_COMPATIBLE_PROP, i, NULL), uname; i++) - emit_label_val(ctx, i ? "" : "Compatible", uname); + emit_stringlist(ctx, noffset, FIT_LOADABLE_PROP, "Loadables"); + emit_stringlist(ctx, noffset, FIT_COMPATIBLE_PROP, "Compatible"); /* Process all hash subnodes of the component configuration node */ for (ndepth = 0, noffset = fdt_next_node(fit, noffset, &ndepth); @@ -405,8 +414,7 @@ void fit_print(struct fit_print_ctx *ctx) ret = fit_get_desc(fit, 0, &desc); emit_label_val(ctx, "FIT description", ret ? "unavailable" : desc); - if (IMAGE_ENABLE_TIMESTAMP) - emit_timestamp(ctx, 0, "Created"); + emit_timestamp(ctx, 0, "Created"); /* Find images parent node offset */ images_noffset = fdt_path_offset(fit, FIT_IMAGES_PATH);