[PATCH v5 21/26] fdt: Drop CONFIG_SPL_BUILD check in fdtdec_setup()

Simon Glass sjg at chromium.org
Tue Oct 26 02:23:39 CEST 2021


Move this to the header file to clean up the C code.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

(no changes since v1)

 include/fdtdec.h | 14 ++++++++++++++
 lib/fdtdec.c     |  6 +-----
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/include/fdtdec.h b/include/fdtdec.h
index 239814228d7..386f6611294 100644
--- a/include/fdtdec.h
+++ b/include/fdtdec.h
@@ -111,6 +111,20 @@ struct fdt_pci_addr {
 extern u8 __dtb_dt_begin[];	/* embedded device tree blob */
 extern u8 __dtb_dt_spl_begin[];	/* embedded device tree blob for SPL/TPL */
 
+/* Get a pointer to the embedded devicetree, if there is one, else NULL */
+static inline u8 *dtb_dt_embedded(void)
+{
+#ifdef CONFIG_OF_EMBED
+# ifdef CONFIG_SPL_BUILD
+	return __dtb_dt_spl_begin;
+# else
+	return __dtb_dt_begin;
+# endif
+#else
+	return NULL;
+#endif
+}
+
 /**
  * Compute the size of a resource.
  *
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 15a990e5b98..69877baaaf5 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -1626,11 +1626,7 @@ int fdtdec_setup(void)
 #if CONFIG_IS_ENABLED(OF_CONTROL)
 # ifdef CONFIG_OF_EMBED
 	/* Get a pointer to the FDT */
-#  ifdef CONFIG_SPL_BUILD
-	gd->fdt_blob = __dtb_dt_spl_begin;
-#  else
-	gd->fdt_blob = __dtb_dt_begin;
-#  endif
+	gd->fdt_blob = dtb_dt_embedded();
 # elif defined(CONFIG_OF_BOARD) || defined(CONFIG_OF_SEPARATE)
 	/* Allow the board to override the fdt address. */
 	gd->fdt_blob = board_fdt_blob_setup();
-- 
2.33.0.1079.g6e70778dc9-goog



More information about the U-Boot mailing list