Adjust this to require the CONFIG option be provided, so that instead of: CONFIG_IS_ENABLED(FOO)
you must write: CONFIG_IS_ENABLED(CONFIG_FOO) This is in preparation for dropping this and just using it is as the new implementation of IS_ENABLED(). For now, update IS_ENABLED() to use CONFIG_IS_ENABLED(), so we can rely on the three-argument version. Signed-off-by: Simon Glass <s...@chromium.org> --- arch/x86/lib/fsp/fsp_dram.c | 2 +- board/st/stm32mp1/stm32mp1.c | 2 +- drivers/fastboot/fb_command.c | 16 ++++++++-------- include/linux/kconfig.h | 34 ++++++++++++---------------------- test/dm/ofnode.c | 2 +- test/lib/kconfig.c | 6 +++--- test/lib/kconfig_spl.c | 4 ++-- 7 files changed, 28 insertions(+), 38 deletions(-) diff --git a/arch/x86/lib/fsp/fsp_dram.c b/arch/x86/lib/fsp/fsp_dram.c index db4e3ff5fa2..13e89d41727 100644 --- a/arch/x86/lib/fsp/fsp_dram.c +++ b/arch/x86/lib/fsp/fsp_dram.c @@ -152,7 +152,7 @@ unsigned int install_e820_map(unsigned int max_entries, if (IS_ENABLED(CONFIG_HAVE_ACPI_RESUME)) { ulong stack_size; - stack_size = CONFIG_IS_ENABLED(HAVE_ACPI_RESUME, + stack_size = IS_ENABLED(CONFIG_HAVE_ACPI_RESUME, (CONFIG_STACK_SIZE_RESUME), (0)); /* * Everything between U-Boot's stack and ram top needs to be diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c index 0ffcca419f2..6dd44396185 100644 --- a/board/st/stm32mp1/stm32mp1.c +++ b/board/st/stm32mp1/stm32mp1.c @@ -903,7 +903,7 @@ const char *env_ext4_get_dev_part(void) int mmc_get_env_dev(void) { - const int mmc_env_dev = CONFIG_IS_ENABLED(ENV_IS_IN_MMC, (CONFIG_SYS_MMC_ENV_DEV), (-1)); + const int mmc_env_dev = IS_ENABLED(CONFIG_ENV_IS_IN_MMC, (CONFIG_SYS_MMC_ENV_DEV), (-1)); if (mmc_env_dev >= 0) return mmc_env_dev; diff --git a/drivers/fastboot/fb_command.c b/drivers/fastboot/fb_command.c index 71cfaec6e9d..3a5e29861a2 100644 --- a/drivers/fastboot/fb_command.c +++ b/drivers/fastboot/fb_command.c @@ -56,11 +56,11 @@ static const struct { }, [FASTBOOT_COMMAND_FLASH] = { .command = "flash", - .dispatch = CONFIG_IS_ENABLED(FASTBOOT_FLASH, (flash), (NULL)) + .dispatch = IS_ENABLED(CONFIG_FASTBOOT_FLASH, (flash), (NULL)) }, [FASTBOOT_COMMAND_ERASE] = { .command = "erase", - .dispatch = CONFIG_IS_ENABLED(FASTBOOT_FLASH, (erase), (NULL)) + .dispatch = IS_ENABLED(CONFIG_FASTBOOT_FLASH, (erase), (NULL)) }, [FASTBOOT_COMMAND_BOOT] = { .command = "boot", @@ -92,27 +92,27 @@ static const struct { }, [FASTBOOT_COMMAND_OEM_FORMAT] = { .command = "oem format", - .dispatch = CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_FORMAT, (oem_format), (NULL)) + .dispatch = IS_ENABLED(CONFIG_FASTBOOT_CMD_OEM_FORMAT, (oem_format), (NULL)) }, [FASTBOOT_COMMAND_OEM_PARTCONF] = { .command = "oem partconf", - .dispatch = CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_PARTCONF, (oem_partconf), (NULL)) + .dispatch = IS_ENABLED(CONFIG_FASTBOOT_CMD_OEM_PARTCONF, (oem_partconf), (NULL)) }, [FASTBOOT_COMMAND_OEM_BOOTBUS] = { .command = "oem bootbus", - .dispatch = CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_BOOTBUS, (oem_bootbus), (NULL)) + .dispatch = IS_ENABLED(CONFIG_FASTBOOT_CMD_OEM_BOOTBUS, (oem_bootbus), (NULL)) }, [FASTBOOT_COMMAND_OEM_RUN] = { .command = "oem run", - .dispatch = CONFIG_IS_ENABLED(FASTBOOT_OEM_RUN, (run_ucmd), (NULL)) + .dispatch = IS_ENABLED(CONFIG_FASTBOOT_OEM_RUN, (run_ucmd), (NULL)) }, [FASTBOOT_COMMAND_UCMD] = { .command = "UCmd", - .dispatch = CONFIG_IS_ENABLED(FASTBOOT_UUU_SUPPORT, (run_ucmd), (NULL)) + .dispatch = IS_ENABLED(CONFIG_FASTBOOT_UUU_SUPPORT, (run_ucmd), (NULL)) }, [FASTBOOT_COMMAND_ACMD] = { .command = "ACmd", - .dispatch = CONFIG_IS_ENABLED(FASTBOOT_UUU_SUPPORT, (run_acmd), (NULL)) + .dispatch = IS_ENABLED(CONFIG_FASTBOOT_UUU_SUPPORT, (run_acmd), (NULL)) }, }; diff --git a/include/linux/kconfig.h b/include/linux/kconfig.h index f00686eb3e1..57d5afc7a1a 100644 --- a/include/linux/kconfig.h +++ b/include/linux/kconfig.h @@ -32,12 +32,6 @@ #define __config_enabled(arg1_or_junk, def_val) ___config_enabled(arg1_or_junk 1, def_val) #define ___config_enabled(__ignored, val, ...) val -/* - * IS_ENABLED(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y', - * 0 otherwise. - */ -#define IS_ENABLED(option) config_enabled(option, 0) - #define __config_val(cfg) CONFIG_ ## cfg #define CONFIG_VAL(option) __config_val(option) @@ -83,34 +77,30 @@ long invalid_use_of_IF_ENABLED_INT(void); #define __CONFIG_IS_ENABLED_1(option) __CONFIG_IS_ENABLED_3(option, (1), (0)) #define __CONFIG_IS_ENABLED_2(option, case1) __CONFIG_IS_ENABLED_3(option, case1, ()) #define __CONFIG_IS_ENABLED_3(option, case1, case0) \ - __concat(__unwrap, config_enabled(CONFIG_VAL(option), 0)) (case1, case0) + __concat(__unwrap, config_enabled(option, 0)) (case1, case0) /* - * CONFIG_IS_ENABLED(FOO) returns 1 if CONFIG_FOO is enabled for the phase being - * built, else 0. Note that CONFIG_FOO corresponds to CONFIG_SPL_FOO (in - * Kconfig) for the SPL phase, CONFIG_TPL_FOO for the TPL phase, etc. - * - * The _nospl version of a CONFIG is emitted by kconfig when an option has no - * SPL equivalent. So in that case there is a CONFIG_xxx for example, but not a - * CONFIG_SPL_xxx - * - * This is needed as a transition measure while CONFIG_IS_ENABLED() is used on - * options without SPL equivalent, since in that case it should always return - * zero. Once we add SPL equivalents, this clause can be dropped. + * CONFIG_IS_ENABLED(CONFIG_FOO) returns 1 if CONFIG_FOO is enabled for the + * phase being built, else 0. * * The optional second and third arguments must be parenthesized; that * allows one to include a trailing comma, e.g. for use in * - * CONFIG_IS_ENABLED(ACME, ({.compatible = "acme,frobnozzle"},)) + * CONFIG_IS_ENABLED(CONFIG_ACME, ({.compatible = "acme,frobnozzle"},)) * - * which adds an entry to the array being defined if CONFIG_ACME (or - * CONFIG_SPL_ACME/CONFIG_TPL_ACME, depending on build context) is + * which adds an entry to the array being defined if CONFIG_ACME is * set, and nothing otherwise. */ #define CONFIG_IS_ENABLED(option, ...) \ __concat(__CONFIG_IS_ENABLED_, __count_args(option, ##__VA_ARGS__)) (option, ##__VA_ARGS__) +/* + * IS_ENABLED(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y', + * 0 otherwise. + */ +#define IS_ENABLED(option, ...) CONFIG_IS_ENABLED(option, ##__VA_ARGS__) + #ifndef __ASSEMBLY__ /* * Detect usage of a the value when the conditional is not enabled. When used @@ -125,7 +115,7 @@ long invalid_use_of_CONFIG_IF_ENABLED_INT(void); * otherwise build error */ #define CONFIG_IF_ENABLED_INT(option, int_option) \ - CONFIG_IS_ENABLED(option, (CONFIG_VAL(int_option)), \ + CONFIG_IS_ENABLED(option, (int_option), \ (invalid_use_of_CONFIG_IF_ENABLED_INT())) #define CONFIG_IF_INT(option, int_option) \ diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c index 8077affabb7..8aec458c3c5 100644 --- a/test/dm/ofnode.c +++ b/test/dm/ofnode.c @@ -1148,7 +1148,7 @@ DM_TEST(dm_test_ofnode_get_name, UT_TESTF_SCAN_FDT); /* try to access more FDTs than is supported */ static int dm_test_ofnode_too_many(struct unit_test_state *uts) { - const int max_trees = CONFIG_IS_ENABLED(OFNODE_MULTI_TREE, + const int max_trees = IS_ENABLED(CONFIG_OFNODE_MULTI_TREE, (CONFIG_OFNODE_MULTI_TREE_MAX), (1)); const int fdt_size = 256; const int num_trees = max_trees + 1; diff --git a/test/lib/kconfig.c b/test/lib/kconfig.c index 8fb6422c905..029a2be8cd9 100644 --- a/test/lib/kconfig.c +++ b/test/lib/kconfig.c @@ -25,7 +25,7 @@ static int lib_test_is_enabled(struct unit_test_state *uts) ut_asserteq(0xc000, IF_ENABLED_INT(CONFIG_BLOBLIST_FIXED, CONFIG_BLOBLIST_ADDR)); ut_asserteq(0xc000, - CONFIG_IF_ENABLED_INT(BLOBLIST_FIXED, BLOBLIST_ADDR)); + CONFIG_IF_ENABLED_INT(CONFIG_BLOBLIST_FIXED, CONFIG_BLOBLIST_ADDR)); /* * This fails if CONFIG_TEST_KCONFIG_ENABLE is not enabled, since the @@ -48,8 +48,8 @@ static int lib_test_is_enabled(struct unit_test_state *uts) */ if (!IS_ENABLED(CONFIG_SANDBOX_SPL) && IS_ENABLED(CONFIG_TEST_KCONFIG)) { - val = CONFIG_IF_ENABLED_INT(TEST_KCONFIG_ENABLE, - TEST_KCONFIG_VALUE); + val = CONFIG_IF_ENABLED_INT(CONFIG_TEST_KCONFIG_ENABLE, + CONFIG_TEST_KCONFIG_VALUE); printf("value2 %ld\n", val); } diff --git a/test/lib/kconfig_spl.c b/test/lib/kconfig_spl.c index 5c66183dc3d..2894a03f1e8 100644 --- a/test/lib/kconfig_spl.c +++ b/test/lib/kconfig_spl.c @@ -34,8 +34,8 @@ static int lib_test_spl_is_enabled(struct unit_test_state *uts) * value is used. */ if (IS_ENABLED(CONFIG_TEST_KCONFIG)) { - val = CONFIG_IF_ENABLED_INT(TEST_KCONFIG_ENABLE, - TEST_KCONFIG_VALUE); + val = CONFIG_IF_ENABLED_INT(CONFIG_TEST_KCONFIG_ENABLE, + CONFIG_TEST_KCONFIG_VALUE); printf("value2 %ld\n", val); } -- 2.39.1.456.gfc5497dd1b-goog