[Concept,11/30] fit: Refactor fit_print_contents() to use new fit_print()

Message ID 20251120025614.2215587-12-sjg@u-boot.org
State New
Headers
Series fit: Improve and test the code to print FIT info |

Commit Message

Simon Glass Nov. 20, 2025, 2:55 a.m. UTC
  From: Simon Glass <simon.glass@canonical.com>

Create a new fit_print() function containing the logic from
fit_print_contents(), and make fit_print_contents() call it.
This allows future callers to use fit_print() directly as we add more
features.

Tidy up the function comments so that they are in the header.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---

 boot/image-fit.c | 34 ++++++----------------------------
 include/image.h  | 45 ++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 50 insertions(+), 29 deletions(-)
  

Patch

diff --git a/boot/image-fit.c b/boot/image-fit.c
index eb47c00cc01..9103016bd08 100644
--- a/boot/image-fit.c
+++ b/boot/image-fit.c
@@ -368,19 +368,7 @@  static void fit_conf_print(const void *fit, int noffset, const char *p)
 	}
 }
 
-/**
- * fit_print_contents - prints out the contents of the FIT format image
- * @fit: pointer to the FIT format image header
- * @p: pointer to prefix string
- *
- * fit_print_contents() formats a multi line FIT image contents description.
- * The routine prints out FIT image properties (root node level) followed by
- * the details of each component image.
- *
- * returns:
- *     no returned results
- */
-void fit_print_contents(const void *fit)
+void fit_print(const void *fit)
 {
 	const char *desc;
 	char *uname;
@@ -472,21 +460,11 @@  void fit_print_contents(const void *fit)
 	}
 }
 
-/**
- * fit_image_print - prints out the FIT component image details
- * @fit: pointer to the FIT format image header
- * @image_noffset: offset of the component image node
- * @p: pointer to prefix string
- *
- * fit_image_print() lists all mandatory properties for the processed component
- * image. If present, hash nodes are printed out as well. Load
- * address for images of type firmware is also printed out. Since the load
- * address is not mandatory for firmware images, it will be output as
- * "unavailable" when not present.
- *
- * returns:
- *     no returned results
- */
+void fit_print_contents(const void *fit)
+{
+	fit_print(fit);
+}
+
 void fit_image_print(const void *fit, int image_noffset, const char *p)
 {
 	uint8_t type, arch, os, comp = IH_COMP_NONE;
diff --git a/include/image.h b/include/image.h
index 33eb5d71e79..2f9469e2709 100644
--- a/include/image.h
+++ b/include/image.h
@@ -1198,9 +1198,52 @@  int fit_parse_subimage(const char *spec, ulong addr_curr,
 		ulong *addr, const char **image_name);
 
 int fit_get_subimage_count(const void *fit, int images_noffset);
-void fit_print_contents(const void *fit);
+
+/**
+ * fit_print() - prints out the contents of the FIT format image
+ * @fit: pointer to the FIT format image header
+ * @p: pointer to prefix string
+ *
+ * This formats a multi line FIT image contents description.
+ * The routine prints out FIT image properties (root node level) followed by
+ * the details of each component image.
+ *
+ * returns:
+ *     no returned results
+ */
+void fit_print(const void *fit);
+
+/**
+ * fit_image_print - prints out the FIT component image details
+ * @fit: pointer to the FIT format image header
+ * @image_noffset: offset of the component image node
+ * @p: pointer to prefix string
+ *
+ * fit_image_print() lists all mandatory properties for the processed component
+ * image. If present, hash nodes are printed out as well. Load
+ * address for images of type firmware is also printed out. Since the load
+ * address is not mandatory for firmware images, it will be output as
+ * "unavailable" when not present.
+ *
+ * returns:
+ *     no returned results
+ */
 void fit_image_print(const void *fit, int noffset, const char *p);
 
+/**
+ * fit_print_contents() - prints out the contents of the FIT format image
+ * @fit: pointer to the FIT format image header
+ * @p: pointer to prefix string
+ *
+ * This formats a multi line FIT image contents description.
+ * The routine prints out FIT image properties (root node level) followed by
+ * the details of each component image.
+ *
+ * returns:
+ *     no returned results
+ */
+void fit_print_contents(const void *fit);
+
 /**
  * fit_get_end - get FIT image size
  * @fit: pointer to the FIT format image header