malloc_f: enable SYS_MALLOC_F by default if DM is on

This option has a bool type, not hex.
Fix it and enable it if CONFIG_DM is on because Driver Model always
requires malloc memory.  Devices are scanned twice, before/after
relocation.  CONFIG_SYS_MALLOC_F should be enabled to use malloc
memory before relocation.  As it is board-independent, handle it
globally.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Acked-by: Stephen Warren <swarren@wwwdotorg.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Acked-by: Robert Baldyga <r.baldyga@samsung.com>
diff --git a/Kconfig b/Kconfig
index 8f96c94..b5968d7 100644
--- a/Kconfig
+++ b/Kconfig
@@ -54,7 +54,7 @@
 
 config SYS_MALLOC_F
 	bool "Enable malloc() pool before relocation"
-	default 0x400
+	default y if DM
 	help
 	  Before relocation memory is very limited on many platforms. Still,
 	  we can provide a small malloc() pool if needed. Driver model in
diff --git a/arch/arm/cpu/armv7/exynos/Kconfig b/arch/arm/cpu/armv7/exynos/Kconfig
index 9e47ed3..bd7540a 100644
--- a/arch/arm/cpu/armv7/exynos/Kconfig
+++ b/arch/arm/cpu/armv7/exynos/Kconfig
@@ -80,9 +80,6 @@
 config DM_GPIO
 	default y
 
-config SYS_MALLOC_F
-	default y
-
 source "board/samsung/smdkv310/Kconfig"
 source "board/samsung/trats/Kconfig"
 source "board/samsung/universal_c210/Kconfig"
diff --git a/arch/arm/cpu/armv7/omap3/Kconfig b/arch/arm/cpu/armv7/omap3/Kconfig
index aa2ff46..1f96498 100644
--- a/arch/arm/cpu/armv7/omap3/Kconfig
+++ b/arch/arm/cpu/armv7/omap3/Kconfig
@@ -106,9 +106,6 @@
 config DM_SERIAL
 	default y if DM
 
-config SYS_MALLOC_F
-	default y if DM
-
 config SYS_SOC
 	default "omap3"
 
diff --git a/arch/arm/mach-tegra/Kconfig b/arch/arm/mach-tegra/Kconfig
index fccfd79..fce1c1d 100644
--- a/arch/arm/mach-tegra/Kconfig
+++ b/arch/arm/mach-tegra/Kconfig
@@ -17,9 +17,6 @@
 
 endchoice
 
-config SYS_MALLOC_F
-	default y
-
 config SYS_MALLOC_F_LEN
 	default 0x1800
 
diff --git a/arch/arm/mach-uniphier/Kconfig b/arch/arm/mach-uniphier/Kconfig
index 7fc26dd..288e6ab 100644
--- a/arch/arm/mach-uniphier/Kconfig
+++ b/arch/arm/mach-uniphier/Kconfig
@@ -45,9 +45,6 @@
 
 endchoice
 
-config SYS_MALLOC_F
-	default y
-
 config CMD_PINMON
 	bool "Enable boot mode pins monitor command"
 	default y
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 35d24e4..da27115 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -76,9 +76,6 @@
 config DM_SERIAL
 	default y
 
-config SYS_MALLOC_F
-	default y
-
 config SYS_MALLOC_F_LEN
 	default 0x800
 
diff --git a/board/amcc/canyonlands/Kconfig b/board/amcc/canyonlands/Kconfig
index c0dbd18..46efa7a 100644
--- a/board/amcc/canyonlands/Kconfig
+++ b/board/amcc/canyonlands/Kconfig
@@ -39,8 +39,4 @@
 config DM_SERIAL
 	default y
 
-config SYS_MALLOC_F
-	bool
-	default y
-
 endif
diff --git a/board/ti/am335x/Kconfig b/board/ti/am335x/Kconfig
index 8c45892..7cb006f 100644
--- a/board/ti/am335x/Kconfig
+++ b/board/ti/am335x/Kconfig
@@ -47,7 +47,4 @@
 config DM_SERIAL
 	default y if DM
 
-config SYS_MALLOC_F
-	default y if DM
-
 endif
diff --git a/configs/Linksprite_pcDuino3_fdt_defconfig b/configs/Linksprite_pcDuino3_fdt_defconfig
index 87dd38f..7690d1e 100644
--- a/configs/Linksprite_pcDuino3_fdt_defconfig
+++ b/configs/Linksprite_pcDuino3_fdt_defconfig
@@ -13,4 +13,3 @@
 CONFIG_DRAM_CLK=480
 CONFIG_DRAM_ZQ=122
 CONFIG_DRAM_EMR1=4
-CONFIG_SYS_MALLOC_F=y
diff --git a/configs/am335x_igep0033_defconfig b/configs/am335x_igep0033_defconfig
index a439298..7ff0a13 100644
--- a/configs/am335x_igep0033_defconfig
+++ b/configs/am335x_igep0033_defconfig
@@ -3,4 +3,3 @@
 CONFIG_SPL_STACK_R_ADDR=0x82000000
 CONFIG_ARM=y
 CONFIG_TARGET_AM335X_IGEP0033=y
-CONFIG_SYS_MALLOC_F=y
diff --git a/configs/cm_fx6_defconfig b/configs/cm_fx6_defconfig
index 00cbdd2..f10a5c2 100644
--- a/configs/cm_fx6_defconfig
+++ b/configs/cm_fx6_defconfig
@@ -5,4 +5,3 @@
 CONFIG_DM=y
 CONFIG_DM_GPIO=y
 CONFIG_DM_SERIAL=y
-CONFIG_SYS_MALLOC_F=y
diff --git a/configs/cm_t335_defconfig b/configs/cm_t335_defconfig
index 31705f2..d189799 100644
--- a/configs/cm_t335_defconfig
+++ b/configs/cm_t335_defconfig
@@ -1,4 +1,3 @@
 CONFIG_SPL=y
 CONFIG_ARM=y
 CONFIG_TARGET_CM_T335=y
-CONFIG_SYS_MALLOC_F=y
diff --git a/configs/mx6dlsabreauto_defconfig b/configs/mx6dlsabreauto_defconfig
index b3816ec..8bc5e8b 100644
--- a/configs/mx6dlsabreauto_defconfig
+++ b/configs/mx6dlsabreauto_defconfig
@@ -1,6 +1,5 @@
 CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/freescale/mx6qsabreauto/mx6dl.cfg,MX6DL"
 CONFIG_ARM=y
 CONFIG_TARGET_MX6QSABREAUTO=y
-CONFIG_SYS_MALLOC_F=y
 CONFIG_DM=y
 CONFIG_DM_THERMAL=y
diff --git a/configs/mx6qsabreauto_defconfig b/configs/mx6qsabreauto_defconfig
index df09296..ba9e512 100644
--- a/configs/mx6qsabreauto_defconfig
+++ b/configs/mx6qsabreauto_defconfig
@@ -1,6 +1,5 @@
 CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/freescale/mx6qsabreauto/imximage.cfg,MX6Q"
 CONFIG_ARM=y
 CONFIG_TARGET_MX6QSABREAUTO=y
-CONFIG_SYS_MALLOC_F=y
 CONFIG_DM=y
 CONFIG_DM_THERMAL=y
diff --git a/configs/mx6qsabresd_defconfig b/configs/mx6qsabresd_defconfig
index cad4281..1764b39 100644
--- a/configs/mx6qsabresd_defconfig
+++ b/configs/mx6qsabresd_defconfig
@@ -1,6 +1,5 @@
 CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/freescale/mx6sabresd/mx6q_4x_mt41j128.cfg,MX6Q"
 CONFIG_ARM=y
 CONFIG_TARGET_MX6SABRESD=y
-CONFIG_SYS_MALLOC_F=y
 CONFIG_DM=y
 CONFIG_DM_THERMAL=y
diff --git a/configs/mx6sxsabresd_defconfig b/configs/mx6sxsabresd_defconfig
index 12a9bdc..5c862cf 100644
--- a/configs/mx6sxsabresd_defconfig
+++ b/configs/mx6sxsabresd_defconfig
@@ -1,6 +1,5 @@
 CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/freescale/mx6sxsabresd/imximage.cfg,MX6SX"
 CONFIG_ARM=y
 CONFIG_TARGET_MX6SXSABRESD=y
-CONFIG_SYS_MALLOC_F=y
 CONFIG_DM=y
 CONFIG_DM_THERMAL=y
diff --git a/configs/nokia_rx51_defconfig b/configs/nokia_rx51_defconfig
index 48a1b29..20a51e1 100644
--- a/configs/nokia_rx51_defconfig
+++ b/configs/nokia_rx51_defconfig
@@ -4,4 +4,3 @@
 CONFIG_DM=n
 CONFIG_DM_SERIAL=n
 CONFIG_DM_GPIO=n
-CONFIG_SYS_MALLOC_F=y
diff --git a/configs/pcm051_rev1_defconfig b/configs/pcm051_rev1_defconfig
index a8b10d4..08075e7 100644
--- a/configs/pcm051_rev1_defconfig
+++ b/configs/pcm051_rev1_defconfig
@@ -2,4 +2,3 @@
 CONFIG_SYS_EXTRA_OPTIONS="REV1"
 CONFIG_ARM=y
 CONFIG_TARGET_PCM051=y
-CONFIG_SYS_MALLOC_F=y
diff --git a/configs/pcm051_rev3_defconfig b/configs/pcm051_rev3_defconfig
index ef307d9..56deb48 100644
--- a/configs/pcm051_rev3_defconfig
+++ b/configs/pcm051_rev3_defconfig
@@ -2,4 +2,3 @@
 CONFIG_SYS_EXTRA_OPTIONS="REV3"
 CONFIG_ARM=y
 CONFIG_TARGET_PCM051=y
-CONFIG_SYS_MALLOC_F=y
diff --git a/configs/pengwyn_defconfig b/configs/pengwyn_defconfig
index 86f8bbb..6346b57 100644
--- a/configs/pengwyn_defconfig
+++ b/configs/pengwyn_defconfig
@@ -1,4 +1,3 @@
 CONFIG_SPL=y
 CONFIG_ARM=y
 CONFIG_TARGET_PENGWYN=y
-CONFIG_SYS_MALLOC_F=y
diff --git a/configs/pepper_defconfig b/configs/pepper_defconfig
index 438d886..3b042ec 100644
--- a/configs/pepper_defconfig
+++ b/configs/pepper_defconfig
@@ -1,4 +1,3 @@
 CONFIG_SPL=y
 CONFIG_ARM=y
 CONFIG_TARGET_PEPPER=y
-CONFIG_SYS_MALLOC_F=y
diff --git a/configs/rpi_2_defconfig b/configs/rpi_2_defconfig
index 69723d5..3075321 100644
--- a/configs/rpi_2_defconfig
+++ b/configs/rpi_2_defconfig
@@ -1,3 +1,2 @@
 CONFIG_ARM=y
 CONFIG_TARGET_RPI_2=y
-CONFIG_SYS_MALLOC_F=y
diff --git a/configs/rpi_defconfig b/configs/rpi_defconfig
index 1a5a8e2..9379cf0 100644
--- a/configs/rpi_defconfig
+++ b/configs/rpi_defconfig
@@ -1,3 +1,2 @@
 CONFIG_ARM=y
 CONFIG_TARGET_RPI=y
-CONFIG_SYS_MALLOC_F=y
diff --git a/configs/s5p_goni_defconfig b/configs/s5p_goni_defconfig
index 5815667..618e590 100644
--- a/configs/s5p_goni_defconfig
+++ b/configs/s5p_goni_defconfig
@@ -2,4 +2,3 @@
 CONFIG_ARCH_S5PC1XX=y
 CONFIG_TARGET_S5P_GONI=y
 CONFIG_DEFAULT_DEVICE_TREE="s5pc1xx-goni"
-CONFIG_SYS_MALLOC_F=y
diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index a0e19ad..a216039 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -5,7 +5,6 @@
 CONFIG_FIT_SIGNATURE=y
 CONFIG_DM=y
 CONFIG_DEFAULT_DEVICE_TREE="sandbox"
-CONFIG_SYS_MALLOC_F=y
 CONFIG_CROS_EC=y
 CONFIG_DM_CROS_EC=y
 CONFIG_CROS_EC_SANDBOX=y
diff --git a/configs/smdkc100_defconfig b/configs/smdkc100_defconfig
index 585fea6..041030f 100644
--- a/configs/smdkc100_defconfig
+++ b/configs/smdkc100_defconfig
@@ -2,4 +2,3 @@
 CONFIG_TARGET_SMDKC100=y
 CONFIG_ARCH_S5PC1XX=y
 CONFIG_DEFAULT_DEVICE_TREE="s5pc1xx-smdkc100"
-CONFIG_SYS_MALLOC_F=y
diff --git a/configs/snapper9260_defconfig b/configs/snapper9260_defconfig
index 9a0d0ad..576d9c5 100644
--- a/configs/snapper9260_defconfig
+++ b/configs/snapper9260_defconfig
@@ -5,4 +5,3 @@
 CONFIG_DM=y
 CONFIG_DM_GPIO=y
 CONFIG_DM_SERIAL=y
-CONFIG_SYS_MALLOC_F=y
diff --git a/configs/snapper9g20_defconfig b/configs/snapper9g20_defconfig
index 82f7a07..07a2643 100644
--- a/configs/snapper9g20_defconfig
+++ b/configs/snapper9g20_defconfig
@@ -5,4 +5,3 @@
 CONFIG_DM=y
 CONFIG_DM_GPIO=y
 CONFIG_DM_SERIAL=y
-CONFIG_SYS_MALLOC_F=y
diff --git a/configs/stv0991_defconfig b/configs/stv0991_defconfig
index 1c9ba88..e8cf311 100644
--- a/configs/stv0991_defconfig
+++ b/configs/stv0991_defconfig
@@ -1,7 +1,6 @@
 CONFIG_SYS_EXTRA_OPTIONS="stv0991"
 CONFIG_ARM=y
 CONFIG_TARGET_STV0991=y
-CONFIG_SYS_MALLOC_F=y
 CONFIG_SYS_MALLOC_F_LEN=0x2000
 CONFIG_DM=y
 CONFIG_DM_SERIAL=y
diff --git a/include/configs/rcar-gen2-common.h b/include/configs/rcar-gen2-common.h
index e9ef7cc..c33f1cb 100644
--- a/include/configs/rcar-gen2-common.h
+++ b/include/configs/rcar-gen2-common.h
@@ -35,8 +35,6 @@
 #define CONFIG_SYS_THUMB_BUILD
 #define CONFIG_SYS_GENERIC_BOARD
 
-#define CONFIG_SYS_MALLOC_F_LEN	(1 << 10)
-
 /* Support File sytems */
 #define CONFIG_FAT_WRITE
 #define CONFIG_DOS_PARTITION