Skip to contentSkip to conversation

x86: Use IS_ENABLED() for built-in-or-module checks

PATCH Applied Thorsten Blum 3 participants 5 messages Aug 4 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 x86: Use IS_ENABLED() for built-in-or-module checks

Replace open-coded built-in-or-module checks for CONFIG_APM, CONFIG_EDD, and CONFIG_X86_SPEEDSTEP_SMI with IS_ENABLED().

---
 arch/x86/boot/edd.c     |  2 +-
 arch/x86/boot/main.c    | 10 ++++------
 arch/x86/kernel/setup.c |  5 ++---
 3 files changed, 7 insertions(+), 10 deletions(-)
arch/x86/boot/edd.c +1 -1
index 1fb4bc70cee9..97cad16f6bf2 100644
@@ -15,7 +15,7 @@
 #include <linux/edd.h>
 #include "string.h"
 
-#if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE)
+#if IS_ENABLED(CONFIG_EDD)
 
 /*
  * Read the MBR (first sector) from a specific device.
arch/x86/boot/main.c +4 -6
index 9d0fea18d3c8..4e382d95ef9a 100644
@@ -164,14 +164,12 @@ void main(void)
 	query_ist();
 
 	/* Query APM information */
-#if defined(CONFIG_APM) || defined(CONFIG_APM_MODULE)
-	query_apm_bios();
-#endif
+	if (IS_ENABLED(CONFIG_APM))
+		query_apm_bios();
 
 	/* Query EDD information */
-#if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE)
-	query_edd();
-#endif
+	if (IS_ENABLED(CONFIG_EDD))
+		query_edd();
 
 	/* Set the video mode */
 	set_video();
arch/x86/kernel/setup.c +2 -3
index 46882ce79c3a..fca42b178b3c 100644
@@ -120,8 +120,7 @@ struct cpuinfo_x86 new_cpu_data;
 struct apm_info apm_info;
 EXPORT_SYMBOL(apm_info);
 
-#if defined(CONFIG_X86_SPEEDSTEP_SMI) || \
-	defined(CONFIG_X86_SPEEDSTEP_SMI_MODULE)
+#if IS_ENABLED(CONFIG_X86_SPEEDSTEP_SMI)
 struct ist_info ist_info;
 EXPORT_SYMBOL(ist_info);
 #else
@@ -230,7 +229,7 @@ char builtin_cmdline[COMMAND_LINE_SIZE] = CONFIG_CMDLINE;
 bool builtin_cmdline_added __ro_after_init;
 #endif
 
-#if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE)
+#if IS_ENABLED(CONFIG_EDD)
 struct edd edd;
 #ifdef CONFIG_EDD_MODULE
 EXPORT_SYMBOL(edd);
#1 lore raw

PATCH 2/2 x86/boot: Use bool and IS_ENABLED() in query_edd()

In query_edd(), use bool for do_edd and initialize it directly from CONFIG_EDD_OFF via IS_ENABLED(). Also use bool for do_mbr and be_quiet.

---
 arch/x86/boot/edd.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)
arch/x86/boot/edd.c +7 -11
index 97cad16f6bf2..9956c611574b 100644
@@ -120,26 +120,22 @@ static int get_edd_info(u8 devno, struct edd_info *ei)
 void query_edd(void)
 {
 	char eddarg[8];
-	int do_mbr = 1;
-#ifdef CONFIG_EDD_OFF
-	int do_edd = 0;
-#else
-	int do_edd = 1;
-#endif
-	int be_quiet;
+	bool do_mbr = true;
+	bool do_edd = !IS_ENABLED(CONFIG_EDD_OFF);
+	bool be_quiet;
 	int devno;
 	struct edd_info ei, *edp;
 	u32 *mbrptr;
 
 	if (cmdline_find_option("edd", eddarg, sizeof(eddarg)) > 0) {
 		if (!strcmp(eddarg, "skipmbr") || !strcmp(eddarg, "skip")) {
-			do_edd = 1;
-			do_mbr = 0;
+			do_edd = true;
+			do_mbr = false;
 		}
 		else if (!strcmp(eddarg, "off"))
-			do_edd = 0;
+			do_edd = false;
 		else if (!strcmp(eddarg, "on"))
-			do_edd = 1;
+			do_edd = true;
 	}
 
 	be_quiet = cmdline_find_option_bool("quiet");
#3 lore raw
In reply to Thorsten Blum
Quoted 2 lines · Thorsten Blum

Replace open-coded built-in-or-module checks for CONFIG_APM, CONFIG_EDD, and CONFIG_X86_SPEEDSTEP_SMI with IS_ENABLED().

Please include the phrase "No change in functionality intended." or so in the changelog, when there's no side effect expected.

Thanks,

Ingo

merge bot Applied
#2 lore raw

[tip: x86/boot] x86/boot: Use bool and IS_ENABLED() to simplify query_edd()

In reply to Thorsten Blum
The following commit has been merged into the x86/boot branch of tip:

The following commit has been merged into the x86/boot branch of tip:

Commit-ID:     2082fec6d4c65b4031dc82daa10cc9a5d35654c9
Gitweb:        https://git.kernel.org/tip/2082fec6d4c65b4031dc82daa10cc9a5d35654c9
Author:        Thorsten Blum <[email protected]>
AuthorDate:    Tue, 04 Aug 2026 13:52:26 +02:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Tue, 04 Aug 2026 19:45:55 +02:00

x86/boot: Use bool and IS_ENABLED() to simplify query_edd()

In query_edd(), use bool for do_edd and initialize it directly from CONFIG_EDD_OFF via IS_ENABLED(). Also use bool for do_mbr and be_quiet.

No change in functionality intended.

---
 arch/x86/boot/edd.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)
arch/x86/boot/edd.c +7 -11
index 97cad16..9956c61 100644
@@ -120,26 +120,22 @@ static int get_edd_info(u8 devno, struct edd_info *ei)
 void query_edd(void)
 {
 	char eddarg[8];
-	int do_mbr = 1;
-#ifdef CONFIG_EDD_OFF
-	int do_edd = 0;
-#else
-	int do_edd = 1;
-#endif
-	int be_quiet;
+	bool do_mbr = true;
+	bool do_edd = !IS_ENABLED(CONFIG_EDD_OFF);
+	bool be_quiet;
 	int devno;
 	struct edd_info ei, *edp;
 	u32 *mbrptr;
 
 	if (cmdline_find_option("edd", eddarg, sizeof(eddarg)) > 0) {
 		if (!strcmp(eddarg, "skipmbr") || !strcmp(eddarg, "skip")) {
-			do_edd = 1;
-			do_mbr = 0;
+			do_edd = true;
+			do_mbr = false;
 		}
 		else if (!strcmp(eddarg, "off"))
-			do_edd = 0;
+			do_edd = false;
 		else if (!strcmp(eddarg, "on"))
-			do_edd = 1;
+			do_edd = true;
 	}
 
 	be_quiet = cmdline_find_option_bool("quiet");
merge bot Applied
#4 lore raw

[tip: x86/boot] x86/boot: Use IS_ENABLED() to simplify built-in-or-module checks

In reply to Thorsten Blum
The following commit has been merged into the x86/boot branch of tip:

The following commit has been merged into the x86/boot branch of tip:

Commit-ID:     2ea3973d4f8483a9654e1e0e2c648f78ca527011
Gitweb:        https://git.kernel.org/tip/2ea3973d4f8483a9654e1e0e2c648f78ca527011
Author:        Thorsten Blum <[email protected]>
AuthorDate:    Tue, 04 Aug 2026 13:52:25 +02:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Tue, 04 Aug 2026 19:45:55 +02:00

x86/boot: Use IS_ENABLED() to simplify built-in-or-module checks

Replace open-coded built-in-or-module checks for CONFIG_APM, CONFIG_EDD, and CONFIG_X86_SPEEDSTEP_SMI with IS_ENABLED().

No change in functionality intended.

---
 arch/x86/boot/edd.c     |  2 +-
 arch/x86/boot/main.c    | 10 ++++------
 arch/x86/kernel/setup.c |  5 ++---
 3 files changed, 7 insertions(+), 10 deletions(-)
arch/x86/boot/edd.c +1 -1
index 1fb4bc7..97cad16 100644
@@ -15,7 +15,7 @@
 #include <linux/edd.h>
 #include "string.h"
 
-#if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE)
+#if IS_ENABLED(CONFIG_EDD)
 
 /*
  * Read the MBR (first sector) from a specific device.
arch/x86/boot/main.c +4 -6
index 9d0fea1..4e382d9 100644
@@ -164,14 +164,12 @@ void main(void)
 	query_ist();
 
 	/* Query APM information */
-#if defined(CONFIG_APM) || defined(CONFIG_APM_MODULE)
-	query_apm_bios();
-#endif
+	if (IS_ENABLED(CONFIG_APM))
+		query_apm_bios();
 
 	/* Query EDD information */
-#if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE)
-	query_edd();
-#endif
+	if (IS_ENABLED(CONFIG_EDD))
+		query_edd();
 
 	/* Set the video mode */
 	set_video();
arch/x86/kernel/setup.c +2 -3
index 46882ce..fca42b1 100644
@@ -120,8 +120,7 @@ struct cpuinfo_x86 new_cpu_data;
 struct apm_info apm_info;
 EXPORT_SYMBOL(apm_info);
 
-#if defined(CONFIG_X86_SPEEDSTEP_SMI) || \
-	defined(CONFIG_X86_SPEEDSTEP_SMI_MODULE)
+#if IS_ENABLED(CONFIG_X86_SPEEDSTEP_SMI)
 struct ist_info ist_info;
 EXPORT_SYMBOL(ist_info);
 #else
@@ -230,7 +229,7 @@ char builtin_cmdline[COMMAND_LINE_SIZE] = CONFIG_CMDLINE;
 bool builtin_cmdline_added __ro_after_init;
 #endif
 
-#if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE)
+#if IS_ENABLED(CONFIG_EDD)
 struct edd edd;
 #ifdef CONFIG_EDD_MODULE
 EXPORT_SYMBOL(edd);