Skip to contentSkip to conversation

x86/boot: Removed quiet flag and switched quiet output to debug flag

PATCH In review Joe Millenbach 2 participants 14 messages Jul 20, 2012 – Jul 22, 2012 1 message not in the archive x86

lore
Share & tools
lore
#1 lore raw

PATCH 1/7 x86/boot: Removed quiet flag and switched quiet output to debug flag

In reply to a message not in the archive

There are only 3 uses of the quiet flag and they all protect output that is only useful for debugging the stub, therefore we switched to using the debug flag for all extra output.

---
 arch/x86/boot/compressed/misc.c |    9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
arch/x86/boot/compressed/misc.c +3 -6
index 7116dcb..8f2355d 100644
@@ -108,7 +108,6 @@ static void error(char *m);
  * This is set up by the setup-routine at boot-time
  */
 struct boot_params *real_mode;		/* Pointer to real-mode data */
-static int quiet;
 static int debug;
 
 void *memset(void *s, int c, size_t n);
@@ -294,7 +293,7 @@ static void parse_elf(void *output)
 		return;
 	}
 
-	if (!quiet)
+	if (debug)
 		putstr("Parsing ELF... ");
 
 	phdrs = malloc(sizeof(*phdrs) * ehdr.e_phnum);
@@ -332,8 +331,6 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
 {
 	real_mode = rmode;
 
-	if (cmdline_find_option_bool("quiet"))
-		quiet = 1;
 	if (cmdline_find_option_bool("debug"))
 		debug = 1;
 
@@ -369,11 +366,11 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
 		error("Wrong destination address");
 #endif
 
-	if (!quiet)
+	if (debug)
 		putstr("\nDecompressing Linux... ");
 	decompress(input_data, input_len, NULL, NULL, output, NULL, error);
 	parse_elf(output);
-	if (!quiet)
+	if (debug)
 		putstr("done.\nBooting the kernel.\n");
 	return;
 }
Signature · 1 line
1.7.9.5
#3 lore raw

PATCH 2/7 x86/boot: Wrap debug printing in a new debug_putstr function

In reply to a message not in the archive

Change all instances of if (debug) putstr(...) to a new debug_putstr(...). This allows a future change to conditionally stub out debug_putstr to save space.

---
 arch/x86/boot/compressed/misc.c |   18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
arch/x86/boot/compressed/misc.c +10 -8
index 8f2355d..49c6d56 100644
@@ -223,6 +223,12 @@ void __putstr(int error, const char *s)
 	outb(0xff & (pos >> 1), vidport+1);
 }
 
+static void debug_putstr(const char *s)
+{
+	if (debug)
+		putstr(s);
+}
+
 void *memset(void *s, int c, size_t n)
 {
 	int i;
@@ -293,8 +299,7 @@ static void parse_elf(void *output)
 		return;
 	}
 
-	if (debug)
-		putstr("Parsing ELF... ");
+	debug_putstr("Parsing ELF... ");
 
 	phdrs = malloc(sizeof(*phdrs) * ehdr.e_phnum);
 	if (!phdrs)
@@ -346,8 +351,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
 	cols = real_mode->screen_info.orig_video_cols;
 
 	console_init();
-	if (debug)
-		putstr("early console in decompress_kernel\n");
+	debug_putstr("early console in decompress_kernel\n");
 
 	free_mem_ptr     = heap;	/* Heap */
 	free_mem_end_ptr = heap + BOOT_HEAP_SIZE;
@@ -366,11 +370,9 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
 		error("Wrong destination address");
 #endif
 
-	if (debug)
-		putstr("\nDecompressing Linux... ");
+	debug_putstr("\nDecompressing Linux... ");
 	decompress(input_data, input_len, NULL, NULL, output, NULL, error);
 	parse_elf(output);
-	if (debug)
-		putstr("done.\nBooting the kernel.\n");
+	debug_putstr("done.\nBooting the kernel.\n");
 	return;
 }
Signature · 1 line
1.7.9.5
#5 lore raw

PATCH 3/7 x86/boot: Changed error putstr path to match new debug_putstr format

In reply to a message not in the archive

For consistency we changed the error output path to match the new debug path.

---
 arch/x86/boot/compressed/misc.c |    6 +++---
 arch/x86/boot/compressed/misc.h |    1 +
 2 files changed, 4 insertions(+), 3 deletions(-)
arch/x86/boot/compressed/misc.c +3 -3
index 49c6d56..de1d54d 100644
@@ -270,9 +270,9 @@ void *memcpy(void *dest, const void *src, size_t n)
 
 static void error(char *x)
 {
-	__putstr(1, "\n\n");
-	__putstr(1, x);
-	__putstr(1, "\n\n -- System halted");
+	error_putstr("\n\n");
+	error_putstr(x);
+	error_putstr("\n\n -- System halted");
 
 	while (1)
 		asm("hlt");
arch/x86/boot/compressed/misc.h +1 -0
index 3f19c81..4c1bfb6 100644
@@ -26,6 +26,7 @@
 extern struct boot_params *real_mode;		/* Pointer to real-mode data */
 void __putstr(int error, const char *s);
 #define putstr(__x)  __putstr(0, __x)
+#define error_putstr(__x)  __putstr(1, __x)
 #define puts(__x)  __putstr(0, __x)
 
 /* cmdline.c */
Signature · 1 line
1.7.9.5
#11 lore raw

PATCH 6/7 x86/boot: Exclude early_serial_console.c if can't use it.

In reply to a message not in the archive

Removes early_serial_console.c code if we don't have the config option that enables it (EARLY_PRINTK). When disabling this code, make early_serial_base a constant 0 to allow the compiler to optimize away the code that checks for early_serial_base.

---
 arch/x86/boot/compressed/early_serial_console.c |    4 ++++
 arch/x86/boot/compressed/misc.h                 |   10 ++++++++++
 2 files changed, 14 insertions(+)
arch/x86/boot/compressed/early_serial_console.c +4 -0
index 261e81f..d3d003c 100644
@@ -1,5 +1,9 @@
 #include "misc.h"
 
+#ifdef CONFIG_EARLY_PRINTK
+
 int early_serial_base;
 
 #include "../early_serial_console.c"
+
+#endif
arch/x86/boot/compressed/misc.h +10 -0
index 618e5c8..3ffee6e 100644
@@ -43,7 +43,17 @@ int cmdline_find_option(const char *option, char *buffer, int bufsize);
 int cmdline_find_option_bool(const char *option);
 
 /* early_serial_console.c */
+#ifdef CONFIG_EARLY_PRINTK
+
 extern int early_serial_base;
 void console_init(void);
 
+#else
+
+static const int early_serial_base;
+static inline void console_init(void)
+{ }
+
+#endif
+
 #endif
Signature · 1 line
1.7.9.5
#13 lore raw

PATCH 7/7 x86/boot: Exclude cmdline.c if you can't use it

In reply to a message not in the archive

From: Gokul Caushik <[email protected]>

CONFIG_EARLY_PRINTK is the only feature that might use command line parsing in the decompression stage. If it is disabled then we can exclude the related code to save space. This can result in an estimated space savings of 2240 bytes from the compressed kernel image.

---
 arch/x86/boot/compressed/cmdline.c |    4 ++++
 arch/x86/boot/compressed/misc.h    |    5 +++--
 2 files changed, 7 insertions(+), 2 deletions(-)
arch/x86/boot/compressed/cmdline.c +4 -0
index cb62f78..10f6b11 100644
@@ -1,5 +1,7 @@
 #include "misc.h"
 
+#ifdef CONFIG_EARLY_PRINTK
+
 static unsigned long fs;
 static inline void set_fs(unsigned long seg)
 {
@@ -19,3 +21,5 @@ int cmdline_find_option_bool(const char *option)
 {
 	return __cmdline_find_option_bool(real_mode->hdr.cmd_line_ptr, option);
 }
+
+#endif
arch/x86/boot/compressed/misc.h +3 -2
index 3ffee6e..0e6dc0e 100644
@@ -38,18 +38,19 @@ static inline void debug_putstr(const char *s)
 
 #endif
 
+#ifdef CONFIG_EARLY_PRINTK
+
 /* cmdline.c */
 int cmdline_find_option(const char *option, char *buffer, int bufsize);
 int cmdline_find_option_bool(const char *option);
 
 /* early_serial_console.c */
-#ifdef CONFIG_EARLY_PRINTK
-
 extern int early_serial_base;
 void console_init(void);
 
 #else
 
+/* early_serial_console.c */
 static const int early_serial_base;
 static inline void console_init(void)
 { }
Signature · 1 line
1.7.9.5
#9 lore raw

PATCH 5/7 x86/boot: Removed unused debug flag and set code

In reply to a message not in the archive

As we're no longer using the flag we don't need to extract the value from the command line and store it. This is a step towards removing command line parameter code.

---
 arch/x86/boot/compressed/misc.c |    4 ----
 1 file changed, 4 deletions(-)
arch/x86/boot/compressed/misc.c +0 -4
index 8c29f82..88f7ff6 100644
@@ -108,7 +108,6 @@ static void error(char *m);
  * This is set up by the setup-routine at boot-time
  */
 struct boot_params *real_mode;		/* Pointer to real-mode data */
-static int debug;
 
 void *memset(void *s, int c, size_t n);
 void *memcpy(void *dest, const void *src, size_t n);
@@ -326,9 +325,6 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
 {
 	real_mode = rmode;
 
-	if (cmdline_find_option_bool("debug"))
-		debug = 1;
-
 	if (real_mode->screen_info.orig_video_mode == 7) {
 		vidmem = (char *) 0xb0000;
 		vidport = 0x3b4;
Signature · 1 line
1.7.9.5
#7 lore raw

PATCH 4/7 x86/boot: Switch output functions from command-line flags to conditional compilation

In reply to a message not in the archive

Changed putstr flagging from parameter to conditional compilation for puts, debug_putstr, and error_putstr. This allows for space savings since most configurations won't use this feature.

---
 arch/x86/boot/compressed/misc.c |   12 +-----------
 arch/x86/boot/compressed/misc.h |   17 +++++++++++++----
 2 files changed, 14 insertions(+), 15 deletions(-)
arch/x86/boot/compressed/misc.c +1 -11
index de1d54d..8c29f82 100644
@@ -169,15 +169,11 @@ static void serial_putchar(int ch)
 	outb(ch, early_serial_base + TXR);
 }
 
-void __putstr(int error, const char *s)
+void __putstr(const char *s)
 {
 	int x, y, pos;
 	char c;
 
-#ifndef CONFIG_X86_VERBOSE_BOOTUP
-	if (!error)
-		return;
-#endif
 	if (early_serial_base) {
 		const char *str = s;
 		while (*str) {
@@ -223,12 +219,6 @@ void __putstr(int error, const char *s)
 	outb(0xff & (pos >> 1), vidport+1);
 }
 
-static void debug_putstr(const char *s)
-{
-	if (debug)
-		putstr(s);
-}
-
 void *memset(void *s, int c, size_t n)
 {
 	int i;
arch/x86/boot/compressed/misc.h +13 -4
index 4c1bfb6..618e5c8 100644
@@ -24,10 +24,19 @@
 
 /* misc.c */
 extern struct boot_params *real_mode;		/* Pointer to real-mode data */
-void __putstr(int error, const char *s);
-#define putstr(__x)  __putstr(0, __x)
-#define error_putstr(__x)  __putstr(1, __x)
-#define puts(__x)  __putstr(0, __x)
+void __putstr(const char *s);
+#define error_putstr(__x)  __putstr(__x)
+
+#ifdef CONFIG_X86_VERBOSE_BOOTUP
+
+#define debug_putstr(__x)  __putstr(__x)
+
+#else
+
+static inline void debug_putstr(const char *s)
+{ }
+
+#endif
 
 /* cmdline.c */
 int cmdline_find_option(const char *option, char *buffer, int bufsize);
Signature · 1 line
1.7.9.5
#2 lore raw

[tip:x86/boot] x86, boot: Removed quiet flag and switched quiet output to debug flag

In reply to Joe Millenbach
Commit-ID:  9f4e4392cbf72d731a489a3217fe810820b8ba96
Gitweb:     http://git.kernel.org/tip/9f4e4392cbf72d731a489a3217fe810820b8ba96
Author:     Joe Millenbach <[email protected]>
AuthorDate: Thu, 19 Jul 2012 18:04:36 -0700
Committer:  H. Peter Anvin <[email protected]>
CommitDate: Sat, 21 Jul 2012 11:07:15 -0700

x86, boot: Removed quiet flag and switched quiet output to debug flag

There are only 3 uses of the quiet flag and they all protect output that is only useful for debugging the stub, therefore we switched to using the debug flag for all extra output.

---
 arch/x86/boot/compressed/misc.c |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)
arch/x86/boot/compressed/misc.c +3 -6
index 7116dcb..8f2355d 100644
@@ -108,7 +108,6 @@ static void error(char *m);
  * This is set up by the setup-routine at boot-time
  */
 struct boot_params *real_mode;		/* Pointer to real-mode data */
-static int quiet;
 static int debug;
 
 void *memset(void *s, int c, size_t n);
@@ -294,7 +293,7 @@ static void parse_elf(void *output)
 		return;
 	}
 
-	if (!quiet)
+	if (debug)
 		putstr("Parsing ELF... ");
 
 	phdrs = malloc(sizeof(*phdrs) * ehdr.e_phnum);
@@ -332,8 +331,6 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
 {
 	real_mode = rmode;
 
-	if (cmdline_find_option_bool("quiet"))
-		quiet = 1;
 	if (cmdline_find_option_bool("debug"))
 		debug = 1;
 
@@ -369,11 +366,11 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
 		error("Wrong destination address");
 #endif
 
-	if (!quiet)
+	if (debug)
 		putstr("\nDecompressing Linux... ");
 	decompress(input_data, input_len, NULL, NULL, output, NULL, error);
 	parse_elf(output);
-	if (!quiet)
+	if (debug)
 		putstr("done.\nBooting the kernel.\n");
 	return;
 }
#4 lore raw

[tip:x86/boot] x86, boot: Wrap debug printing in a new debug_putstr function

In reply to Joe Millenbach
Commit-ID:  e605a425975b073aafebbb2c09d3ae266be2fd3e
Gitweb:     http://git.kernel.org/tip/e605a425975b073aafebbb2c09d3ae266be2fd3e
Author:     Joe Millenbach <[email protected]>
AuthorDate: Thu, 19 Jul 2012 18:04:37 -0700
Committer:  H. Peter Anvin <[email protected]>
CommitDate: Sat, 21 Jul 2012 11:07:18 -0700

x86, boot: Wrap debug printing in a new debug_putstr function

Change all instances of if (debug) putstr(...) to a new debug_putstr(...). This allows a future change to conditionally stub out debug_putstr to save space.

---
 arch/x86/boot/compressed/misc.c |   18 ++++++++++--------
 1 files changed, 10 insertions(+), 8 deletions(-)
arch/x86/boot/compressed/misc.c +10 -8
index 8f2355d..49c6d56 100644
@@ -223,6 +223,12 @@ void __putstr(int error, const char *s)
 	outb(0xff & (pos >> 1), vidport+1);
 }
 
+static void debug_putstr(const char *s)
+{
+	if (debug)
+		putstr(s);
+}
+
 void *memset(void *s, int c, size_t n)
 {
 	int i;
@@ -293,8 +299,7 @@ static void parse_elf(void *output)
 		return;
 	}
 
-	if (debug)
-		putstr("Parsing ELF... ");
+	debug_putstr("Parsing ELF... ");
 
 	phdrs = malloc(sizeof(*phdrs) * ehdr.e_phnum);
 	if (!phdrs)
@@ -346,8 +351,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
 	cols = real_mode->screen_info.orig_video_cols;
 
 	console_init();
-	if (debug)
-		putstr("early console in decompress_kernel\n");
+	debug_putstr("early console in decompress_kernel\n");
 
 	free_mem_ptr     = heap;	/* Heap */
 	free_mem_end_ptr = heap + BOOT_HEAP_SIZE;
@@ -366,11 +370,9 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
 		error("Wrong destination address");
 #endif
 
-	if (debug)
-		putstr("\nDecompressing Linux... ");
+	debug_putstr("\nDecompressing Linux... ");
 	decompress(input_data, input_len, NULL, NULL, output, NULL, error);
 	parse_elf(output);
-	if (debug)
-		putstr("done.\nBooting the kernel.\n");
+	debug_putstr("done.\nBooting the kernel.\n");
 	return;
 }
#6 lore raw

[tip:x86/boot] x86, boot: Changed error putstr path to match new debug_putstr format

In reply to Joe Millenbach
Commit-ID:  cb454fe10400566214ec690318a0167ff7f5b8ca
Gitweb:     http://git.kernel.org/tip/cb454fe10400566214ec690318a0167ff7f5b8ca
Author:     Joe Millenbach <[email protected]>
AuthorDate: Thu, 19 Jul 2012 18:04:38 -0700
Committer:  H. Peter Anvin <[email protected]>
CommitDate: Sat, 21 Jul 2012 11:07:22 -0700

x86, boot: Changed error putstr path to match new debug_putstr format

For consistency we changed the error output path to match the new debug path.

---
 arch/x86/boot/compressed/misc.c |    6 +++---
 arch/x86/boot/compressed/misc.h |    1 +
 2 files changed, 4 insertions(+), 3 deletions(-)
arch/x86/boot/compressed/misc.c +3 -3
index 49c6d56..de1d54d 100644
@@ -270,9 +270,9 @@ void *memcpy(void *dest, const void *src, size_t n)
 
 static void error(char *x)
 {
-	__putstr(1, "\n\n");
-	__putstr(1, x);
-	__putstr(1, "\n\n -- System halted");
+	error_putstr("\n\n");
+	error_putstr(x);
+	error_putstr("\n\n -- System halted");
 
 	while (1)
 		asm("hlt");
arch/x86/boot/compressed/misc.h +1 -0
index 3f19c81..4c1bfb6 100644
@@ -26,6 +26,7 @@
 extern struct boot_params *real_mode;		/* Pointer to real-mode data */
 void __putstr(int error, const char *s);
 #define putstr(__x)  __putstr(0, __x)
+#define error_putstr(__x)  __putstr(1, __x)
 #define puts(__x)  __putstr(0, __x)
 
 /* cmdline.c */
#8 lore raw

[tip:x86/boot] x86, boot: Switch output functions from command-line flags to conditional compilation

In reply to Joe Millenbach
Commit-ID:  7aac3015b533add3e85222f9fd2ab66216b38746
Gitweb:     http://git.kernel.org/tip/7aac3015b533add3e85222f9fd2ab66216b38746
Author:     Joe Millenbach <[email protected]>
AuthorDate: Thu, 19 Jul 2012 18:04:39 -0700
Committer:  H. Peter Anvin <[email protected]>
CommitDate: Sat, 21 Jul 2012 11:07:25 -0700

x86, boot: Switch output functions from command-line flags to conditional compilation

Changed putstr flagging from parameter to conditional compilation for puts, debug_putstr, and error_putstr. This allows for space savings since most configurations won't use this feature.

---
 arch/x86/boot/compressed/misc.c |   12 +-----------
 arch/x86/boot/compressed/misc.h |   17 +++++++++++++----
 2 files changed, 14 insertions(+), 15 deletions(-)
arch/x86/boot/compressed/misc.c +1 -11
index de1d54d..8c29f82 100644
@@ -169,15 +169,11 @@ static void serial_putchar(int ch)
 	outb(ch, early_serial_base + TXR);
 }
 
-void __putstr(int error, const char *s)
+void __putstr(const char *s)
 {
 	int x, y, pos;
 	char c;
 
-#ifndef CONFIG_X86_VERBOSE_BOOTUP
-	if (!error)
-		return;
-#endif
 	if (early_serial_base) {
 		const char *str = s;
 		while (*str) {
@@ -223,12 +219,6 @@ void __putstr(int error, const char *s)
 	outb(0xff & (pos >> 1), vidport+1);
 }
 
-static void debug_putstr(const char *s)
-{
-	if (debug)
-		putstr(s);
-}
-
 void *memset(void *s, int c, size_t n)
 {
 	int i;
arch/x86/boot/compressed/misc.h +13 -4
index 4c1bfb6..618e5c8 100644
@@ -24,10 +24,19 @@
 
 /* misc.c */
 extern struct boot_params *real_mode;		/* Pointer to real-mode data */
-void __putstr(int error, const char *s);
-#define putstr(__x)  __putstr(0, __x)
-#define error_putstr(__x)  __putstr(1, __x)
-#define puts(__x)  __putstr(0, __x)
+void __putstr(const char *s);
+#define error_putstr(__x)  __putstr(__x)
+
+#ifdef CONFIG_X86_VERBOSE_BOOTUP
+
+#define debug_putstr(__x)  __putstr(__x)
+
+#else
+
+static inline void debug_putstr(const char *s)
+{ }
+
+#endif
 
 /* cmdline.c */
 int cmdline_find_option(const char *option, char *buffer, int bufsize);
#10 lore raw

[tip:x86/boot] x86, boot: Removed unused debug flag and set code

In reply to Joe Millenbach
Commit-ID:  641a1cebfe2f05fa1a48503d816fc70cf707d033
Gitweb:     http://git.kernel.org/tip/641a1cebfe2f05fa1a48503d816fc70cf707d033
Author:     Joe Millenbach <[email protected]>
AuthorDate: Thu, 19 Jul 2012 18:04:40 -0700
Committer:  H. Peter Anvin <[email protected]>
CommitDate: Sat, 21 Jul 2012 11:07:29 -0700

x86, boot: Removed unused debug flag and set code

As we're no longer using the flag we don't need to extract the value from the command line and store it. This is a step towards removing command line parameter code.

---
 arch/x86/boot/compressed/misc.c |    4 ----
 1 files changed, 0 insertions(+), 4 deletions(-)
arch/x86/boot/compressed/misc.c +0 -4
index 8c29f82..88f7ff6 100644
@@ -108,7 +108,6 @@ static void error(char *m);
  * This is set up by the setup-routine at boot-time
  */
 struct boot_params *real_mode;		/* Pointer to real-mode data */
-static int debug;
 
 void *memset(void *s, int c, size_t n);
 void *memcpy(void *dest, const void *src, size_t n);
@@ -326,9 +325,6 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
 {
 	real_mode = rmode;
 
-	if (cmdline_find_option_bool("debug"))
-		debug = 1;
-
 	if (real_mode->screen_info.orig_video_mode == 7) {
 		vidmem = (char *) 0xb0000;
 		vidport = 0x3b4;
#12 lore raw

[tip:x86/boot] x86, boot: Exclude early_serial_console.c if can' t use it.

In reply to Joe Millenbach
Commit-ID:  cec49df9d331feaa2fea3d24c07147c7659940d1
Gitweb:     http://git.kernel.org/tip/cec49df9d331feaa2fea3d24c07147c7659940d1
Author:     Joe Millenbach <[email protected]>
AuthorDate: Thu, 19 Jul 2012 18:04:41 -0700
Committer:  H. Peter Anvin <[email protected]>
CommitDate: Sat, 21 Jul 2012 11:07:34 -0700

x86, boot: Exclude early_serial_console.c if can't use it.

Removes early_serial_console.c code if we don't have the config option that enables it (EARLY_PRINTK). When disabling this code, make early_serial_base a constant 0 to allow the compiler to optimize away the code that checks for early_serial_base.

---
 arch/x86/boot/compressed/early_serial_console.c |    4 ++++
 arch/x86/boot/compressed/misc.h                 |   10 ++++++++++
 2 files changed, 14 insertions(+), 0 deletions(-)
arch/x86/boot/compressed/early_serial_console.c +4 -0
index 261e81f..d3d003c 100644
@@ -1,5 +1,9 @@
 #include "misc.h"
 
+#ifdef CONFIG_EARLY_PRINTK
+
 int early_serial_base;
 
 #include "../early_serial_console.c"
+
+#endif
arch/x86/boot/compressed/misc.h +10 -0
index 618e5c8..3ffee6e 100644
@@ -43,7 +43,17 @@ int cmdline_find_option(const char *option, char *buffer, int bufsize);
 int cmdline_find_option_bool(const char *option);
 
 /* early_serial_console.c */
+#ifdef CONFIG_EARLY_PRINTK
+
 extern int early_serial_base;
 void console_init(void);
 
+#else
+
+static const int early_serial_base;
+static inline void console_init(void)
+{ }
+
+#endif
+
 #endif
#14 lore raw

[tip:x86/boot] x86, boot: Exclude cmdline.c if you can't use it

In reply to Joe Millenbach
Commit-ID:  bd448d4d0a1bd88dc6fdc41217b2c25383fa8529
Gitweb:     http://git.kernel.org/tip/bd448d4d0a1bd88dc6fdc41217b2c25383fa8529
Author:     Gokul Caushik <[email protected]>
AuthorDate: Thu, 19 Jul 2012 18:04:42 -0700
Committer:  H. Peter Anvin <[email protected]>
CommitDate: Sat, 21 Jul 2012 11:07:39 -0700

x86, boot: Exclude cmdline.c if you can't use it

CONFIG_EARLY_PRINTK is the only feature that might use command line parsing in the decompression stage. If it is disabled then we can exclude the related code to save space. This can result in an estimated space savings of 2240 bytes from the compressed kernel image.

---
 arch/x86/boot/compressed/cmdline.c |    4 ++++
 arch/x86/boot/compressed/misc.h    |    5 +++--
 2 files changed, 7 insertions(+), 2 deletions(-)
arch/x86/boot/compressed/cmdline.c +4 -0
index cb62f78..10f6b11 100644
@@ -1,5 +1,7 @@
 #include "misc.h"
 
+#ifdef CONFIG_EARLY_PRINTK
+
 static unsigned long fs;
 static inline void set_fs(unsigned long seg)
 {
@@ -19,3 +21,5 @@ int cmdline_find_option_bool(const char *option)
 {
 	return __cmdline_find_option_bool(real_mode->hdr.cmd_line_ptr, option);
 }
+
+#endif
arch/x86/boot/compressed/misc.h +3 -2
index 3ffee6e..0e6dc0e 100644
@@ -38,18 +38,19 @@ static inline void debug_putstr(const char *s)
 
 #endif
 
+#ifdef CONFIG_EARLY_PRINTK
+
 /* cmdline.c */
 int cmdline_find_option(const char *option, char *buffer, int bufsize);
 int cmdline_find_option_bool(const char *option);
 
 /* early_serial_console.c */
-#ifdef CONFIG_EARLY_PRINTK
-
 extern int early_serial_base;
 void console_init(void);
 
 #else
 
+/* early_serial_console.c */
 static const int early_serial_base;
 static inline void console_init(void)
 { }