[PATCH v3 89/95] kconfig: drop config_opt_enabled()

Simon Glass sjg at chromium.org
Mon Feb 13 00:16:32 CET 2023


This is include used in three places. It does not appear in Linux. Use
IS_ENABLED() instead since it provides a similar feature, albeit needing
brackets.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

(no changes since v1)

 drivers/fastboot/fb_command.c | 12 ++++++------
 drivers/fastboot/fb_common.c  |  4 ++--
 include/linux/kconfig.h       | 11 -----------
 net/tftp.c                    |  3 ++-
 4 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/drivers/fastboot/fb_command.c b/drivers/fastboot/fb_command.c
index 3a5e29861a2..23a18a26aa6 100644
--- a/drivers/fastboot/fb_command.c
+++ b/drivers/fastboot/fb_command.c
@@ -424,8 +424,8 @@ static void reboot_recovery(char *cmd_parameter, char *response)
 static void __maybe_unused oem_format(char *cmd_parameter, char *response)
 {
 	char cmdbuf[32];
-	const int mmc_dev = config_opt_enabled(CONFIG_FASTBOOT_FLASH_MMC,
-					       CONFIG_FASTBOOT_FLASH_MMC_DEV, -1);
+	const int mmc_dev = IS_ENABLED(CONFIG_FASTBOOT_FLASH_MMC,
+				       (CONFIG_FASTBOOT_FLASH_MMC_DEV), (-1));
 
 	if (!env_get("partitions")) {
 		fastboot_fail("partitions not set", response);
@@ -447,8 +447,8 @@ static void __maybe_unused oem_format(char *cmd_parameter, char *response)
 static void __maybe_unused oem_partconf(char *cmd_parameter, char *response)
 {
 	char cmdbuf[32];
-	const int mmc_dev = config_opt_enabled(CONFIG_FASTBOOT_FLASH_MMC,
-					       CONFIG_FASTBOOT_FLASH_MMC_DEV, -1);
+	const int mmc_dev = IS_ENABLED(CONFIG_FASTBOOT_FLASH_MMC,
+				       (CONFIG_FASTBOOT_FLASH_MMC_DEV), (-1));
 
 	if (!cmd_parameter) {
 		fastboot_fail("Expected command parameter", response);
@@ -473,8 +473,8 @@ static void __maybe_unused oem_partconf(char *cmd_parameter, char *response)
 static void __maybe_unused oem_bootbus(char *cmd_parameter, char *response)
 {
 	char cmdbuf[32];
-	const int mmc_dev = config_opt_enabled(CONFIG_FASTBOOT_FLASH_MMC,
-					       CONFIG_FASTBOOT_FLASH_MMC_DEV, -1);
+	const int mmc_dev = IS_ENABLED(CONFIG_FASTBOOT_FLASH_MMC,
+				       (CONFIG_FASTBOOT_FLASH_MMC_DEV), (-1));
 
 	if (!cmd_parameter) {
 		fastboot_fail("Expected command parameter", response);
diff --git a/drivers/fastboot/fb_common.c b/drivers/fastboot/fb_common.c
index 57b6182c46a..70fba02634f 100644
--- a/drivers/fastboot/fb_common.c
+++ b/drivers/fastboot/fb_common.c
@@ -96,8 +96,8 @@ int __weak fastboot_set_reboot_flag(enum fastboot_reboot_reason reason)
 		[FASTBOOT_REBOOT_REASON_FASTBOOTD] = "boot-fastboot",
 		[FASTBOOT_REBOOT_REASON_RECOVERY] = "boot-recovery"
 	};
-	const int mmc_dev = config_opt_enabled(CONFIG_FASTBOOT_FLASH_MMC,
-					       CONFIG_FASTBOOT_FLASH_MMC_DEV, -1);
+	const int mmc_dev = IS_ENABLED(CONFIG_FASTBOOT_FLASH_MMC,
+				       (CONFIG_FASTBOOT_FLASH_MMC_DEV), (-1));
 
 	if (!IS_ENABLED(CONFIG_FASTBOOT_FLASH_MMC))
 		return -EINVAL;
diff --git a/include/linux/kconfig.h b/include/linux/kconfig.h
index a2c8e58cb4d..381f4eb5a1c 100644
--- a/include/linux/kconfig.h
+++ b/include/linux/kconfig.h
@@ -36,17 +36,6 @@
 
 #define CONFIG_VAL(option)  __config_val(option)
 
-/*
- * This uses a similar mechanism to config_enabled() above. If cfg is enabled,
- * it resolves to the value of opt_cfg, otherwise it resolves to def_val
- */
-#define config_opt_enabled(cfg, opt_cfg, def_val) _config_opt_enabled(cfg, opt_cfg, def_val)
-#define _config_opt_enabled(cfg_val, opt_value, def_val) \
-	__config_opt_enabled(__ARG_PLACEHOLDER_##cfg_val, opt_value, def_val)
-#define __config_opt_enabled(arg1_or_junk, arg2, def_val) \
-	___config_opt_enabled(arg1_or_junk arg2, def_val)
-#define ___config_opt_enabled(__ignored, val, ...) val
-
 /*
  * Count number of arguments to a variadic macro. Currently only need
  * it for 1, 2 or 3 arguments.
diff --git a/net/tftp.c b/net/tftp.c
index 88e71e67de3..7c9aa6f5bd2 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -736,7 +736,8 @@ static void sanitize_tftp_block_size_option(enum proto_t protocol)
 
 	switch (protocol) {
 	case TFTPGET:
-		max_defrag = config_opt_enabled(CONFIG_IP_DEFRAG, CONFIG_NET_MAXDEFRAG, 0);
+		max_defrag = IS_ENABLED(CONFIG_IP_DEFRAG,
+					(CONFIG_NET_MAXDEFRAG), (0));
 		if (max_defrag) {
 			/* Account for IP, UDP and TFTP headers. */
 			cap = max_defrag - (20 + 8 + 4);
-- 
2.39.1.581.gbfd45094c4-goog



More information about the U-Boot mailing list