]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
spl: Remove #ifdefs with BOOTSTAGE
authorSimon Glass <sjg@chromium.org>
Tue, 26 Sep 2023 14:14:32 +0000 (08:14 -0600)
committerTom Rini <trini@konsulko.com>
Fri, 6 Oct 2023 18:38:12 +0000 (14:38 -0400)
This feature has some helpers in its header file so that its functions
resolve to nothing when the feature is disabled. Add a few more and use
these to simplify the code.

With this there are no more #ifdefs in board_init_r()

Signed-off-by: Simon Glass <sjg@chromium.org>
common/bootstage.c
common/spl/spl.c
include/bootstage.h

index 326c40f1561fd861dba22a50e082455bd008664e..a68d883c684c5bdf94ed3801e1c513970bde0626 100644 (file)
@@ -502,6 +502,20 @@ int bootstage_unstash(const void *base, int size)
        return 0;
 }
 
+int _bootstage_stash_default(void)
+{
+       return bootstage_stash(map_sysmem(CONFIG_BOOTSTAGE_STASH_ADDR, 0),
+                              CONFIG_BOOTSTAGE_STASH_SIZE);
+}
+
+int _bootstage_unstash_default(void)
+{
+       const void *stash = map_sysmem(CONFIG_BOOTSTAGE_STASH_ADDR,
+                                      CONFIG_BOOTSTAGE_STASH_SIZE);
+
+       return bootstage_unstash(stash, CONFIG_BOOTSTAGE_STASH_SIZE);
+}
+
 int bootstage_get_size(void)
 {
        struct bootstage_data *data = gd->bootstage;
index d676a0312af947a1e07e8443f416bfcaab3fc94f..2239ee933b88d6ae198872f80066a7f2b0385b6a 100644 (file)
@@ -538,17 +538,11 @@ static int spl_common_init(bool setup_malloc)
                      ret);
                return ret;
        }
-#ifdef CONFIG_BOOTSTAGE_STASH
        if (!u_boot_first_phase()) {
-               const void *stash = map_sysmem(CONFIG_BOOTSTAGE_STASH_ADDR,
-                                              CONFIG_BOOTSTAGE_STASH_SIZE);
-
-               ret = bootstage_unstash(stash, CONFIG_BOOTSTAGE_STASH_SIZE);
+               ret = bootstage_unstash_default();
                if (ret)
-                       debug("%s: Failed to unstash bootstage: ret=%d\n",
-                             __func__, ret);
+                       log_debug("Failed to unstash bootstage: ret=%d\n", ret);
        }
-#endif /* CONFIG_BOOTSTAGE_STASH */
        bootstage_mark_name(get_bootstage_id(true),
                            spl_phase_name(spl_phase()));
 #if CONFIG_IS_ENABLED(LOG)
@@ -866,12 +860,9 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
                      gd_malloc_ptr(), gd_malloc_ptr() / 1024);
 
        bootstage_mark_name(get_bootstage_id(false), "end phase");
-#ifdef CONFIG_BOOTSTAGE_STASH
-       ret = bootstage_stash((void *)CONFIG_BOOTSTAGE_STASH_ADDR,
-                             CONFIG_BOOTSTAGE_STASH_SIZE);
+       ret = bootstage_stash_default();
        if (ret)
                debug("Failed to stash bootstage: err=%d\n", ret);
-#endif
 
        if (IS_ENABLED(CONFIG_SPL_VIDEO_REMOVE)) {
                struct udevice *dev;
index 685939ccffc0f85aaa2638e19e28cb1a052b5b81..f9376c320c967860a74faee1b710d2b9013634dd 100644 (file)
@@ -244,6 +244,8 @@ void show_boot_progress(int val);
 
 #ifdef ENABLE_BOOTSTAGE
 
+#include <mapmem.h>
+
 /* This is the full bootstage implementation */
 
 /**
@@ -452,6 +454,26 @@ static inline int bootstage_init(bool first)
 
 #endif /* ENABLE_BOOTSTAGE */
 
+/* helpers for SPL */
+int _bootstage_stash_default(void);
+int _bootstage_unstash_default(void);
+
+static inline int bootstage_stash_default(void)
+{
+       if (CONFIG_IS_ENABLED(BOOTSTAGE) && IS_ENABLED(CONFIG_BOOTSTAGE_STASH))
+               return _bootstage_stash_default();
+
+       return 0;
+}
+
+static inline int bootstage_unstash_default(void)
+{
+       if (CONFIG_IS_ENABLED(BOOTSTAGE) && IS_ENABLED(CONFIG_BOOTSTAGE_STASH))
+               return _bootstage_unstash_default();
+
+       return 0;
+}
+
 /* Helper macro for adding a bootstage to a line of code */
 #define BOOTSTAGE_MARKER()     \
                bootstage_mark_code(__FILE__, __func__, __LINE__)