Skip to contentSkip to conversation

x86/boot, earlyprintk: do not compile early_setup_console if !CONFIG_EARLY_PRINTK

RFC PATCH New Alexander Kuleshov 1 participant 1 message Apr 6, 2015 x86

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 x86/boot, earlyprintk: do not compile early_setup_console if !CONFIG_EARLY_PRINTK

There is the call of the console_init() function in the arch/x86/boot/main.c which tries to find 'earlyprintk' option in the kernel command line. This function called every time regardless of the CONFIG_EARLY_PRINTK, but we no need in it if CONFIG_EARLY_PRINTK is not set.

---
 arch/x86/boot/Makefile               | 6 +++---
 arch/x86/boot/boot.h                 | 6 ++++++
 arch/x86/boot/early_serial_console.c | 2 ++
 arch/x86/boot/tty.c                  | 6 ++++--
 4 files changed, 15 insertions(+), 5 deletions(-)
arch/x86/boot/Makefile +3 -3
index 57bbf2f..e21ebc8 100644
@@ -23,10 +23,10 @@ targets		+= fdimage fdimage144 fdimage288 image.iso mtools.conf
 subdir-		:= compressed
 
 setup-y		+= a20.o bioscall.o cmdline.o copy.o cpu.o cpuflags.o cpucheck.o
-setup-y		+= early_serial_console.o edd.o header.o main.o mca.o memory.o
-setup-y		+= pm.o pmjump.o printf.o regs.o string.o tty.o video.o
-setup-y		+= video-mode.o version.o
+setup-y		+= edd.o header.o main.o mca.o memory.o pm.o pmjump.o printf.o
+setup-y		+= regs.o string.o tty.o video.o video-mode.o version.o
 setup-$(CONFIG_X86_APM_BOOT) += apm.o
+setup-$(CONFIG_EARLY_PRINTK) += early_serial_console.o
 
 # The link order of the video-*.o modules can matter.  In particular,
 # video-vga.o *must* be listed first, followed by video-vesa.o.
arch/x86/boot/boot.h +6 -0
index bd49ec6..5c353d2 100644
@@ -297,9 +297,15 @@ static inline int cmdline_find_option_bool(const char *option)
 int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr);
 int validate_cpu(void);
 
+#ifdef CONFIG_EARLY_PRINTK
 /* early_serial_console.c */
 extern int early_serial_base;
 void console_init(void);
+#else
+static const int early_serial_base;
+static inline void console_init(void)
+{ }
+#endif
 
 /* edd.c */
 void query_edd(void);
arch/x86/boot/early_serial_console.c +2 -0
index 45a0768..5c8e9f8 100644
@@ -1,5 +1,7 @@
 #include "boot.h"
 
+int early_serial_base;
+
 #define DEFAULT_SERIAL_PORT 0x3f8 /* ttyS0 */
 
 #define DLAB		0x80
arch/x86/boot/tty.c +4 -2
index def2451..b5bd9d7 100644
@@ -15,8 +15,6 @@
 
 #include "boot.h"
 
-int early_serial_base;
-
 #define XMTRDY          0x20
 
 #define TXR             0       /*  Transmit register (WRITE) */
@@ -27,6 +25,7 @@ int early_serial_base;
  * error during initialization.
  */
 
+#ifdef CONFIG_EARLY_PRINTK
 static void __attribute__((section(".inittext"))) serial_putchar(int ch)
 {
 	unsigned timeout = 0xffff;
@@ -36,6 +35,7 @@ static void __attribute__((section(".inittext"))) serial_putchar(int ch)
 
 	outb(ch, early_serial_base + TXR);
 }
+#endif
 
 static void __attribute__((section(".inittext"))) bios_putchar(int ch)
 {
@@ -56,8 +56,10 @@ void __attribute__((section(".inittext"))) putchar(int ch)
 
 	bios_putchar(ch);
 
+#ifdef CONFIG_EARLY_PRINTK
 	if (early_serial_base != 0)
 		serial_putchar(ch);
+#endif
 }
 
 void __attribute__((section(".inittext"))) puts(const char *str)
Signature · 1 line
2.3.3.611.g09038fc.dirty