From patchwork Thu Nov 20 02:55:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 747 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=1763607439; bh=UAQCex6b3rxyXY1CGzYHrixn9M26O0RIy84JOmgkwD0=; 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=TM3+s/e7mKhYr4VZVg/ow7p6S4sNqoIHIbmAHHcMVT8aTklbdBO2k0JGn0tx5pzQC FxSe0pwjxU0U/xvsCk/2fVb84RoK9EOtlflRp8pNRlTmNyOiAPm5koB0lauyKH2B4y u1tgxgboq1skuCisboTvrK3O1orlpA7T7kaOSwD1R3zcR4WTNBaM0hiYevFK0ms3eR Njm2jgHQXZtwHp1xuCz0CRliCZbrF62NEeUlRiK1oVAm7Sfl3R9GTIlc2EVHir0dYA l9hvHBByhO9whVdjzSBMd1A9/PN+h1QijOupq03IIhqKVJfFoCVOZRWFQhWbozHxDg A5vFsUBxDk/FA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id CE0C168657 for ; Wed, 19 Nov 2025 19:57:19 -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 IIi49QU1kNWv for ; Wed, 19 Nov 2025 19:57:19 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607439; bh=UAQCex6b3rxyXY1CGzYHrixn9M26O0RIy84JOmgkwD0=; 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=TM3+s/e7mKhYr4VZVg/ow7p6S4sNqoIHIbmAHHcMVT8aTklbdBO2k0JGn0tx5pzQC FxSe0pwjxU0U/xvsCk/2fVb84RoK9EOtlflRp8pNRlTmNyOiAPm5koB0lauyKH2B4y u1tgxgboq1skuCisboTvrK3O1orlpA7T7kaOSwD1R3zcR4WTNBaM0hiYevFK0ms3eR Njm2jgHQXZtwHp1xuCz0CRliCZbrF62NEeUlRiK1oVAm7Sfl3R9GTIlc2EVHir0dYA l9hvHBByhO9whVdjzSBMd1A9/PN+h1QijOupq03IIhqKVJfFoCVOZRWFQhWbozHxDg A5vFsUBxDk/FA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id BC066686BB for ; Wed, 19 Nov 2025 19:57:19 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607438; bh=qEtBrCjDBPg+WrCC6yer/P7eyv9uGWN8A/xBLDc/suc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wlheN6UO++VLvh6MZYyH+ko4z4HvC8GCpeI8YJfWVlvgsxaAkActozEZuZOLM6RP/ Pq3Jr0GWBxDMLC8JEurC4qRc8/yxUWMpzbxOs09zKa5yxefL7nkfq9wfHDe5Hsf39v phknljssLctP5Focbx+wPkyFN8hILOX2+Uce8qmOHDkA0slsa6q+cUM6ETnh6UIZkm 9PAPFLDC9kxT+21sKCi3WR8THtUu45NbmWdsNogt41pDLD9q6BywGXNiH/wHS5NWO4 yHkbblUOavAl1QLRBWcLNz7HHiQHmvOlQqU86HhCFZeiB036RuzrqvU4rqeAm9U8LH xXtMeD4sVLLpw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8D2FA68631; Wed, 19 Nov 2025 19:57:18 -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 gZHwT50XsUwa; Wed, 19 Nov 2025 19:57:18 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607430; bh=nTY5s2M+zAhX7ejQT77vkSxrP5hfx1G0qxZsTWRt1Mw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WsBhc1YCm2fWIOuxgERGqjMjIEWBTeIwZgIeC8wvWLphe/nLGKJWsfDSVkTxO3bSK GEbc79unnL+hcaB0kvl6TB+/GA0C68iDri9do7yJZqelhjVv5da5yxg5mUaxxPBrlI 7SvVxS3PuqPm94CJYjD7NrfbJ9euywiBDIny7A4w9e9wOQgdWw7Oe1FiC2eUoAtVx9 rNHcywk7j4+MUWzOcPQfwz+BzosVV5nP1oinjm7DdA/XaWPiyLV0cXEAyuLuN6Aaux rdjrtnMndR95N4vhr17W0decisGC/F0gEJEaSSA6xAmxp/3j8Qf+e9LrOhoatjxrsz VTeT9Bo/y7JLg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id F114268614; Wed, 19 Nov 2025 19:57:09 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 19 Nov 2025 19:55:54 -0700 Message-ID: <20251120025614.2215587-20-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: MBZWSMJYK5WXK23UXUXK5Q4TXEUIZRLN X-Message-ID-Hash: MBZWSMJYK5WXK23UXUXK5Q4TXEUIZRLN 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 19/30] fit: Add a a function to print labels with values 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 new emit_label_val() helper function that combines emit_label() and printf() for simple label-value pairs. Make use of it where appropriate. Co-developed-by: Claude Signed-off-by: Simon Glass --- boot/fit_print.c | 65 ++++++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 35 deletions(-) diff --git a/boot/fit_print.c b/boot/fit_print.c index 97dab4b2490..3ff53fceded 100644 --- a/boot/fit_print.c +++ b/boot/fit_print.c @@ -75,6 +75,23 @@ static void emit_label(struct fit_print_ctx *ctx, const char *label) printf("%*s", ctx->tab - len, ""); } +/** + * emit_label_val() - print a label with value + * @ctx: pointer to FIT print context + * @label: label string (e.g., "Type" or "OS") + * @val: value string to print after the label + * + * Prints the indentation, label with padding to ctx->tab, and the value + * followed by a newline. This is a convenience function that combines + * emit_label() and printf() for simple label-value pairs. + */ +static void emit_label_val(struct fit_print_ctx *ctx, const char *label, + const char *val) +{ + emit_label(ctx, label); + printf("%s\n", val); +} + /** * fit_image_print_data() - prints out the hash node details * @ctx: pointer to FIT print context @@ -195,11 +212,7 @@ void fit_image_print(struct fit_print_ctx *ctx, int image_noffset) /* Mandatory properties */ ret = fit_get_desc(fit, image_noffset, &desc); - emit_label(ctx, "Description"); - if (ret) - printf("unavailable\n"); - else - printf("%s\n", desc); + emit_label_val(ctx, "Description", ret ? "unavailable" : desc); if (IMAGE_ENABLE_TIMESTAMP) { time_t timestamp; @@ -213,12 +226,10 @@ void fit_image_print(struct fit_print_ctx *ctx, int image_noffset) } fit_image_get_type(fit, image_noffset, &type); - emit_label(ctx, "Type"); - printf("%s\n", genimg_get_type_name(type)); + emit_label_val(ctx, "Type", genimg_get_type_name(type)); fit_image_get_comp(fit, image_noffset, &comp); - emit_label(ctx, "Compression"); - printf("%s\n", genimg_get_comp_name(comp)); + emit_label_val(ctx, "Compression", genimg_get_comp_name(comp)); ret = fit_image_get_data(fit, image_noffset, &data, &size); @@ -244,15 +255,13 @@ void fit_image_print(struct fit_print_ctx *ctx, int image_noffset) type == IH_TYPE_RAMDISK || type == IH_TYPE_FIRMWARE || type == IH_TYPE_FLATDT) { fit_image_get_arch(fit, image_noffset, &arch); - emit_label(ctx, "Architecture"); - printf("%s\n", genimg_get_arch_name(arch)); + emit_label_val(ctx, "Architecture", genimg_get_arch_name(arch)); } if (type == IH_TYPE_KERNEL || type == IH_TYPE_RAMDISK || type == IH_TYPE_FIRMWARE) { fit_image_get_os(fit, image_noffset, &os); - emit_label(ctx, "OS"); - printf("%s\n", genimg_get_os_name(os)); + emit_label_val(ctx, "OS", genimg_get_os_name(os)); } if (type == IH_TYPE_KERNEL || type == IH_TYPE_STANDALONE || @@ -316,31 +325,19 @@ static void fit_conf_print(struct fit_print_ctx *ctx, int noffset) /* Mandatory properties */ ret = fit_get_desc(fit, noffset, &desc); - emit_label(ctx, "Description"); - if (ret) - printf("unavailable\n"); - else - printf("%s\n", desc); + emit_label_val(ctx, "Description", ret ? "unavailable" : desc); uname = fdt_getprop(fit, noffset, FIT_KERNEL_PROP, NULL); - emit_label(ctx, "Kernel"); - if (!uname) - printf("unavailable\n"); - else - printf("%s\n", uname); + emit_label_val(ctx, "Kernel", uname ?: "unavailable"); /* Optional properties */ uname = fdt_getprop(fit, noffset, FIT_RAMDISK_PROP, NULL); - if (uname) { - emit_label(ctx, "Init Ramdisk"); - printf("%s\n", uname); - } + if (uname) + emit_label_val(ctx, "Init Ramdisk", uname); uname = fdt_getprop(fit, noffset, FIT_FIRMWARE_PROP, NULL); - if (uname) { - emit_label(ctx, "Firmware"); - printf("%s\n", uname); - } + if (uname) + emit_label_val(ctx, "Firmware", uname); for (i = 0; uname = fdt_stringlist_get(fit, noffset, FIT_FDT_PROP, @@ -354,10 +351,8 @@ static void fit_conf_print(struct fit_print_ctx *ctx, int noffset) } uname = fdt_getprop(fit, noffset, FIT_FPGA_PROP, NULL); - if (uname) { - emit_label(ctx, "FPGA"); - printf("%s\n", uname); - } + if (uname) + emit_label_val(ctx, "FPGA", uname); /* Print out all of the specified loadables */ for (i = 0;