From patchwork Thu Nov 20 02:55:59 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 752 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=1763607454; bh=Mbww3pawum5hS5B17a6hy8rMd0uLbm251XmHW+CUcBQ=; 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=SPkutXWDYSX/q5LhN28eNhBborK9ObaFAsbWDD7epHm2ZQINPq4zAqsSpvEKzwVp6 wKQDx1zv6VhQaIVVnS/G5Jhi9PMMZtSRsMI8E7S1IWt7HO3Agskpy1L9HirtGuQpD8 ugKu6tpD4X7D2oYsSk6kkVXWG7VuYCncIItaRNPnPRGfiJ4rpBWJE5YW6jUqDoGhmJ EmoP7Q24iG7rOnp/QXG9SBJiPtSzrekv7NyrtN5flAB0cdFB0xbEvgm3n/iTQz7qFM Slc5k33Mz+nA4M/w9jBA2O4PiBPKtLLpmiV5n5qY8cLGGlY5kICIa8frOkni4G2zom f45CDCci52I5Q== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6365E68657 for ; Wed, 19 Nov 2025 19:57:34 -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 Z9UpaUXGwKZY for ; Wed, 19 Nov 2025 19:57:34 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607454; bh=Mbww3pawum5hS5B17a6hy8rMd0uLbm251XmHW+CUcBQ=; 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=SPkutXWDYSX/q5LhN28eNhBborK9ObaFAsbWDD7epHm2ZQINPq4zAqsSpvEKzwVp6 wKQDx1zv6VhQaIVVnS/G5Jhi9PMMZtSRsMI8E7S1IWt7HO3Agskpy1L9HirtGuQpD8 ugKu6tpD4X7D2oYsSk6kkVXWG7VuYCncIItaRNPnPRGfiJ4rpBWJE5YW6jUqDoGhmJ EmoP7Q24iG7rOnp/QXG9SBJiPtSzrekv7NyrtN5flAB0cdFB0xbEvgm3n/iTQz7qFM Slc5k33Mz+nA4M/w9jBA2O4PiBPKtLLpmiV5n5qY8cLGGlY5kICIa8frOkni4G2zom f45CDCci52I5Q== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5286E686B2 for ; Wed, 19 Nov 2025 19:57:34 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607452; bh=b20tkDSc3eQ8hIYEAmPK6bXL4FxIzn0JDFpSkb1Q0TM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HQ51MA1Zu3YC14jzzCp111FFtyOIiotece7AkI3L6M30qwIICmtTl0ZcDqRDr2jAv WyDwTjeTYQUIkDQpvXw/BT9FKZX67qqYLq7owJafnKIyIwZihzvZ8b6+xv1VW+Jn9k bzN3NxXZu+ZEigXvhAhcl3G4xfQRaSNLUlEzgMlaXn3GcAnW1sN3omRCCOMESQj4pi BmJyUWt9koogE9OdVRw6H/IZufdZDjk/wkqKgTEdBHJrYMxR/yY6/5IpwL3iNF9soQ UtZmTtxuAstBKLa9qAJBLNc3uPrcboYLMOrTx8BGW+K54R7zqgb5gczFFan4z6jxYf jn7V9CvVVaUMw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4AB05686B2; Wed, 19 Nov 2025 19:57:32 -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 ec0I-z7-HgDY; Wed, 19 Nov 2025 19:57:32 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607446; bh=STqXynH1GGBnnCK4RYb5zr0zeHam284cUqXyFryUI9s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DKpOY810LmaPXGNFqHYtuoHUsE9ovG3JMLOrs8byD6ILIOk4skBhs8xtknGAHwl8V 71b6UZAo/OEfZK2qFl+zouLiF3+BXKetjJLKP0t7t4FJigcBOL9Jc5VqispDYNp5wH rynkAffglCXtqgg6MY6lcCgZVgvD39/cLwhO7YNvte0oNM9A+6Qgcp5H7cOSOWVg4U P7PE8u146ldZHMlsdlqJdbYjde3uoeVYIeNSrm7DXedX1JbDfzeCEKWDJggcYctUQl ILWElc9yAJ7UDKbNcG5/OgfEBZE6FFrgXZNYhG42L0alRxXWqVAdaA/tyQ3zBgIqxF NTYiJLjoZdt4g== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 7F73068657; Wed, 19 Nov 2025 19:57:26 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 19 Nov 2025 19:55:59 -0700 Message-ID: <20251120025614.2215587-25-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: SRCFCOOQYCABYLZIND3AM5EAPUYH7JCU X-Message-ID-Hash: SRCFCOOQYCABYLZIND3AM5EAPUYH7JCU 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 24/30] fit: Add a helper for timestamp printing 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_timestamp() helper function to handle printing timestamps in FITs. Co-developed-by: Claude Signed-off-by: Simon Glass --- boot/fit_print.c | 56 ++++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/boot/fit_print.c b/boot/fit_print.c index 84836a71090..9696679762d 100644 --- a/boot/fit_print.c +++ b/boot/fit_print.c @@ -111,6 +111,28 @@ static void emit_prop(struct fit_print_ctx *ctx, int noffset, emit_label_val(ctx, label, val); } +/** + * emit_timestamp() - print a timestamp + * @ctx: pointer to FIT print context + * @noffset: offset of the node containing the timestamp + * @label: label string to use when printing + * + * Gets the timestamp from the specified node and prints it with the given + * label. If the timestamp is not available, prints "unavailable" instead. + * This is a convenience function for printing FIT timestamps. + */ +static void emit_timestamp(struct fit_print_ctx *ctx, int noffset, + const char *label) +{ + time_t timestamp; + + emit_label(ctx, label); + if (fit_get_timestamp(ctx->fit, noffset, ×tamp)) + printf("unavailable\n"); + else + genimg_print_time(timestamp); +} + /** * fit_image_print_data() - prints out the hash node details * @ctx: pointer to FIT print context @@ -163,15 +185,8 @@ static void fit_image_print_data(struct fit_print_ctx *ctx, int noffset, debug("%s len: %d\n", type, value_len); /* Signatures have a time stamp */ - if (IMAGE_ENABLE_TIMESTAMP && keyname) { - time_t timestamp; - - emit_label(ctx, "Timestamp"); - if (fit_get_timestamp(fit, noffset, ×tamp)) - printf("unavailable\n"); - else - genimg_print_time(timestamp); - } + if (IMAGE_ENABLE_TIMESTAMP && keyname) + emit_timestamp(ctx, noffset, "Timestamp"); } /** @@ -233,16 +248,8 @@ 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) { - time_t timestamp; - - ret = fit_get_timestamp(fit, 0, ×tamp); - emit_label(ctx, "Created"); - if (ret) - printf("unavailable\n"); - else - genimg_print_time(timestamp); - } + if (IMAGE_ENABLE_TIMESTAMP) + emit_timestamp(ctx, 0, "Created"); fit_image_get_type(fit, image_noffset, &type); emit_label_val(ctx, "Type", genimg_get_type_name(type)); @@ -393,20 +400,13 @@ void fit_print(struct fit_print_ctx *ctx) int ndepth; int count = 0; int ret; - time_t timestamp; /* Root node properties */ ret = fit_get_desc(fit, 0, &desc); emit_label_val(ctx, "FIT description", ret ? "unavailable" : desc); - if (IMAGE_ENABLE_TIMESTAMP) { - ret = fit_get_timestamp(fit, 0, ×tamp); - printf("%*sCreated: ", p, ""); - if (ret) - printf("unavailable\n"); - else - genimg_print_time(timestamp); - } + if (IMAGE_ENABLE_TIMESTAMP) + emit_timestamp(ctx, 0, "Created"); /* Find images parent node offset */ images_noffset = fdt_path_offset(fit, FIT_IMAGES_PATH);