From patchwork Thu Nov 20 02:55:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 751 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=1763607449; bh=0zCXeSet7Qd3ezMEUnS13HpIb4rvtzrNDpKEOALNj2Y=; 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=a0cNvU3oCkw/7w6z1esT+LFmH2Kkp+1tgbvSy6UqLk6BkgQxc99P+FatbkUte2S3m lifeUX2/9K3vHUgMqRhk3YEsLd5A2oTfqBWSVsA1Lae5NjL5hVuHL8hKG6FxetU1sj BMOrVOQ0QZsXU0AMXG63WwS1SgYcK+XT0uoYWU+45mb54QcPSV4FCCBhga+Q9fhbGU GbvUh57QIaQxkJ5Ud48GuKc1Z7Xa52bBgdC0JMLDuzV1VPGV2qBfX3vUNs+1vFA8Zm LRvuYZXRS/yIlcsrV7TdOrbnOprFECFU01pMZELDFhqeERTfA55Dowef8hpUvVOeRS 1ss2b79sek3FQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id F2E2F686F0 for ; Wed, 19 Nov 2025 19:57:29 -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 wICDm6mI2I0c for ; Wed, 19 Nov 2025 19:57:29 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607448; bh=0zCXeSet7Qd3ezMEUnS13HpIb4rvtzrNDpKEOALNj2Y=; 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=vS5Og3s8uxFn2/QzZl85CUVxJs0uiJ6eo7seAMYYWWFKnuWnt3UYtXWi7jrMAU1nb VFwys237wc4s3Yw8+t1FNIE0BHdwz25G9gtoE98gYivz2jCpv6D+AEIjCqrxxflpt3 64lnER6q9GEzQNgQfw/DhBt9wZ87QjmhmXEffXggA9JMc9WC7kTtPPGYRFIRrXpeSp 34LBK3ir4zcpRE+x/H36mk+N/GWS3HWhFL1yx2lG3LVe0iK7la/ydb9f6UKSoJTc0i dPUYcAtER1K06sYCAoT1DxYB7o2EiUuJGCJPvZddXrCmEgx47XMtdgROPhZ2y0CpBK E26DKts/EvHoA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id ED532686B2 for ; Wed, 19 Nov 2025 19:57:28 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607446; bh=ogUyJYDWjFTRHfZ6ncxYUucQp05RLJ1F/yFL08EEJ+Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q7e7dRCqswVvI6zeMvm+5oSSlyT0WflIuiyBBs8G83oVlh1DKdq5o6iWZwEyLcUnP QRYJlBAtKpenJroScgrDM0H+GmRAm4hsxoTm6bnZn+y3sWwmUszvY4urNtiT1IFGc4 1bCT7r73w+lmWg8cxETxFh76zI207PXp0sxxDN/qwkqv9C6lilsghSi2rZ2FXcuYzI DHvrQIaeQcG9sL/XVNzH7AY3JGIM5EMIE/7dGFUNQKB57OzZ3LN2QPG+Fpsz0BmKF5 EPPlIrBatlQcCvAi1ZoepfwbIHvFDcGMyV8Yj5YJblA+Liz8CVBXEuKbouTR8sFMB8 5U1y8tUWEcv4w== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3C43B68668; Wed, 19 Nov 2025 19:57:26 -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 pjivDWzwyNsg; Wed, 19 Nov 2025 19:57:26 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607446; bh=FWAcEd6obvuFeFbtISbIMov3azs2Sx95gkwJHl1ZTdI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Am1nrTE26zvRcnv6kzy905WD3iTK4J2J20pPWrZi76XjVnwT0nFkz0XKjVX5+UMAt DFCURVoqKyP4BSYrhnm0ml1x5qqJUnh9Pnbzvx5KDvks+0mdjtVZBiwPY17FYi6K25 Wu/zXfP7TJI7gCCJOBOpEVd39t6ipghAfn0V2Ey3VWuvYBE1BVtjJo7/D4xEXC0Odl gXI0q16/bR1qO5rsx/UV1R9BgiROI6coTa6fiCsEm6mr03OPnagia/X0z3YYbbkvQI p3nVYKL5ak/hJHqlTEAdXB0CkH42eZqQgHqS5+Qe4dtws43ZHjftrwSKpWXExPjyXB AXWB08rzpsgfQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 97EE768657; Wed, 19 Nov 2025 19:57:25 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 19 Nov 2025 19:55:58 -0700 Message-ID: <20251120025614.2215587-24-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: HNV3QMLAUEIKEXWAMQVIJNQOK2E4FS7O X-Message-ID-Hash: HNV3QMLAUEIKEXWAMQVIJNQOK2E4FS7O 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 23/30] fit: Add a helper to output optional 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 new emit_prop() helper function to simplify printing optional properties in FIT configurations. Co-developed-by: Claude Signed-off-by: Simon Glass --- boot/fit_print.c | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/boot/fit_print.c b/boot/fit_print.c index 628d6108bea..84836a71090 100644 --- a/boot/fit_print.c +++ b/boot/fit_print.c @@ -90,6 +90,27 @@ static void emit_label_val(struct fit_print_ctx *ctx, const char *label, printf("%s\n", val); } +/** + * emit_prop() - print a property if it exists + * @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 property from the specified node and prints it with the given label + * only if the property exists. This is a convenience function for optional + * properties that should only be printed when present. + */ +static void emit_prop(struct fit_print_ctx *ctx, int noffset, + const char *prop, const char *label) +{ + const char *val; + + val = fdt_getprop(ctx->fit, noffset, prop, NULL); + if (val) + emit_label_val(ctx, label, val); +} + /** * fit_image_print_data() - prints out the hash node details * @ctx: pointer to FIT print context @@ -326,13 +347,8 @@ static void fit_conf_print(struct fit_print_ctx *ctx, int noffset) emit_label_val(ctx, "Kernel", uname ?: "unavailable"); /* Optional properties */ - uname = fdt_getprop(fit, noffset, FIT_RAMDISK_PROP, NULL); - if (uname) - emit_label_val(ctx, "Init Ramdisk", uname); - - uname = fdt_getprop(fit, noffset, FIT_FIRMWARE_PROP, NULL); - if (uname) - emit_label_val(ctx, "Firmware", uname); + 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, @@ -340,9 +356,7 @@ static void fit_conf_print(struct fit_print_ctx *ctx, int noffset) i++) emit_label_val(ctx, i ? "" : "FDT", uname); - uname = fdt_getprop(fit, noffset, FIT_FPGA_PROP, NULL); - if (uname) - emit_label_val(ctx, "FPGA", uname); + emit_prop(ctx, noffset, FIT_FPGA_PROP, "FPGA"); /* Print out all of the specified loadables */ for (i = 0;