Skip to contentSkip to conversation

x86, efi: remove duplicate code in setup_arch() by using, efi_is_native()

PATCH Applied Satoru Takeuchi 2 participants 2 messages Feb 14, 2013 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86, efi: remove duplicate code in setup_arch() by using, efi_is_native()

From: Satoru Takeuchi <[email protected]>

The check, "IS_ENABLED(CONFIG_X86_64) != efi_enabled(EFI_64BIT)", in setup_arch() can be replaced by efi_is_enabled(). This change remove duplicate code and improve readability.

Cc Matt Fleming <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
---
 arch/x86/include/asm/efi.h  |    9 ++++++++-
 arch/x86/kernel/setup.c     |    3 +--
 arch/x86/platform/efi/efi.c |    5 -----
 3 files changed, 9 insertions(+), 8 deletions(-)
arch/x86/include/asm/efi.h +8 -1
index 28677c5..60c89f3 100644
@@ -102,7 +102,14 @@ extern void efi_call_phys_epilog(void);
 extern void efi_unmap_memmap(void);
 extern void efi_memory_uc(u64 addr, unsigned long size);
 
-#ifndef CONFIG_EFI
+#ifdef CONFIG_EFI
+
+static inline bool efi_is_native(void)
+{
+	return IS_ENABLED(CONFIG_X86_64) == efi_enabled(EFI_64BIT);
+}
+
+#else
 /*
  * IF EFI is not configured, have the EFI calls return -ENOSYS.
  */
arch/x86/kernel/setup.c +1 -2
index 8b24289..1abb796 100644
@@ -1135,8 +1135,7 @@ void __init setup_arch(char **cmdline_p)
 	 * mismatched firmware/kernel archtectures since there is no
 	 * support for runtime services.
 	 */
-	if (efi_enabled(EFI_BOOT) &&
-	    IS_ENABLED(CONFIG_X86_64) != efi_enabled(EFI_64BIT)) {
+	if (efi_enabled(EFI_BOOT) && !efi_is_native()) {
 		pr_info("efi: Setup done, disabling due to 32/64-bit mismatch\n");
 		efi_unmap_memmap();
 	}
arch/x86/platform/efi/efi.c +0 -5
index 928bf83..eb9faeb 100644
@@ -69,11 +69,6 @@ struct efi_memory_map memmap;
 static struct efi efi_phys __initdata;
 static efi_system_table_t efi_systab __initdata;
 
-static inline bool efi_is_native(void)
-{
-	return IS_ENABLED(CONFIG_X86_64) == efi_enabled(EFI_64BIT);
-}
-
 unsigned long x86_efi_facility;
 
 /*

-- 1.7.10.4

Applied
#2 lore raw
In reply to a message not in the archive
Quoted 11 lines · Satoru Takeuchi

From: Satoru Takeuchi <[email protected]>

The check, "IS_ENABLED(CONFIG_X86_64) != efi_enabled(EFI_64BIT)", in setup_arch() can be replaced by efi_is_enabled(). This change remove duplicate code and improve readability.

Cc Matt Fleming <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Quoted 5 lines
---
 arch/x86/include/asm/efi.h  |    9 ++++++++-
 arch/x86/kernel/setup.c     |    3 +--
 arch/x86/platform/efi/efi.c |    5 -----
 3 files changed, 9 insertions(+), 8 deletions(-)

Applied, thanks!