]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
spl: Avoid #ifdef with CONFIG_SPL_SYS_MALLOC
authorSimon Glass <sjg@chromium.org>
Tue, 26 Sep 2023 14:14:18 +0000 (08:14 -0600)
committerTom Rini <trini@konsulko.com>
Fri, 6 Oct 2023 18:38:11 +0000 (14:38 -0400)
Use IF_ENABLED_INT() to avoid needing to use the preprocessor.

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

index 0f4533655164169642c0ad906c29b51f674ef58b..a58b070d17e9b0d71dc3e82b60449b621cd08271 100644 (file)
@@ -750,10 +750,10 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 
        spl_set_bd();
 
-#if defined(CONFIG_SPL_SYS_MALLOC)
-       mem_malloc_init(SPL_SYS_MALLOC_START, CONFIG_SPL_SYS_MALLOC_SIZE);
-       gd->flags |= GD_FLG_FULL_MALLOC_INIT;
-#endif
+       if (IS_ENABLED(CONFIG_SPL_SYS_MALLOC)) {
+               mem_malloc_init(SPL_SYS_MALLOC_START, SPL_SYS_MALLOC_SIZE);
+               gd->flags |= GD_FLG_FULL_MALLOC_INIT;
+       }
        if (!(gd->flags & GD_FLG_SPL_INIT)) {
                if (spl_init())
                        hang();
index f0a191be590e363500c3218398f3c78ecd68ca27..dca6a86b01f5577b5c7d82dda9abe20d6343a7b2 100644 (file)
  */
 #ifdef CONFIG_SPL_HAS_CUSTOM_MALLOC_START
 #define SPL_SYS_MALLOC_START           CONFIG_SPL_CUSTOM_SYS_MALLOC_ADDR
-#else
+#elif defined(CONFIG_SPL_BSS_START_ADDR)
 #define SPL_SYS_MALLOC_START           (CONFIG_SPL_BSS_START_ADDR + \
                                         CONFIG_SPL_BSS_MAX_SIZE)
+#else
+/* feature not enabled: this value avoids compiler errors but is not used */
+#define SPL_SYS_MALLOC_START   0
 #endif
+#define SPL_SYS_MALLOC_SIZE    \
+       IF_ENABLED_INT(CONFIG_SPL_SYS_MALLOC, CONFIG_SPL_SYS_MALLOC_SIZE)
 
 #endif