spl: Avoid #ifdef with CONFIG_SPL_SYS_MALLOC

Use IF_ENABLED_INT() to avoid needing to use the preprocessor.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass 2023-09-26 08:14:18 -06:00 committed by Tom Rini
parent 9cbdc3a0fc
commit 52779874da
2 changed files with 10 additions and 5 deletions

View 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);
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;
#endif
}
if (!(gd->flags & GD_FLG_SPL_INIT)) {
if (spl_init())
hang();

View file

@ -24,9 +24,14 @@
*/
#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