diff options
| author | Thomas Gleixner <tglx@linutronix.de> | 2013-04-29 19:17:18 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-04-29 21:28:13 -0400 |
| commit | d0380e6c3c0f6edb986d8798a23acfaf33d5df23 (patch) | |
| tree | 454ea23060995d2e1326962cedfd6e86a335629d | |
| parent | 07c65f4d1aa74f7cf1c46d7f96e05cfa3e628ba1 (diff) | |
early_printk: consolidate random copies of identical code
The early console implementations are the same all over the place. Move
the print function to kernel/printk and get rid of the copies.
[akpm@linux-foundation.org: arch/mips/kernel/early_printk.c needs kernel.h for va_list]
[paul.gortmaker@windriver.com: sh4: make the bios early console support depend on EARLY_PRINTK]
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Cc: Russell King <linux@arm.linux.org.uk>
Acked-by: Mike Frysinger <vapier@gentoo.org>
Cc: Michal Simek <monstr@monstr.eu>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Chris Metcalf <cmetcalf@tilera.com>
Cc: Richard Weinberger <richard@nod.at>
Reviewed-by: Ingo Molnar <mingo@kernel.org>
Tested-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
| -rw-r--r-- | arch/arm/kernel/early_printk.c | 17 | ||||
| -rw-r--r-- | arch/blackfin/kernel/early_printk.c | 2 | ||||
| -rw-r--r-- | arch/microblaze/kernel/early_printk.c | 26 | ||||
| -rw-r--r-- | arch/mips/kernel/early_printk.c | 12 | ||||
| -rw-r--r-- | arch/powerpc/kernel/udbg.c | 6 | ||||
| -rw-r--r-- | arch/sh/kernel/sh_bios.c | 4 | ||||
| -rw-r--r-- | arch/tile/kernel/early_printk.c | 27 | ||||
| -rw-r--r-- | arch/um/kernel/early_printk.c | 8 | ||||
| -rw-r--r-- | arch/unicore32/kernel/early_printk.c | 12 | ||||
| -rw-r--r-- | arch/x86/kernel/early_printk.c | 21 | ||||
| -rw-r--r-- | include/linux/console.h | 1 | ||||
| -rw-r--r-- | include/linux/printk.h | 6 | ||||
| -rw-r--r-- | kernel/printk.c | 30 |
13 files changed, 63 insertions, 109 deletions
diff --git a/arch/arm/kernel/early_printk.c b/arch/arm/kernel/early_printk.c index 85aa2b292692..43076536965c 100644 --- a/arch/arm/kernel/early_printk.c +++ b/arch/arm/kernel/early_printk.c | |||
| @@ -29,28 +29,17 @@ static void early_console_write(struct console *con, const char *s, unsigned n) | |||
| 29 | early_write(s, n); | 29 | early_write(s, n); |
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | static struct console early_console = { | 32 | static struct console early_console_dev = { |
| 33 | .name = "earlycon", | 33 | .name = "earlycon", |
| 34 | .write = early_console_write, | 34 | .write = early_console_write, |
| 35 | .flags = CON_PRINTBUFFER | CON_BOOT, | 35 | .flags = CON_PRINTBUFFER | CON_BOOT, |
| 36 | .index = -1, | 36 | .index = -1, |
| 37 | }; | 37 | }; |
| 38 | 38 | ||
| 39 | asmlinkage void early_printk(const char *fmt, ...) | ||
| 40 | { | ||
| 41 | char buf[512]; | ||
| 42 | int n; | ||
| 43 | va_list ap; | ||
| 44 | |||
| 45 | va_start(ap, fmt); | ||
| 46 | n = vscnprintf(buf, sizeof(buf), fmt, ap); | ||
| 47 | early_write(buf, n); | ||
| 48 | va_end(ap); | ||
| 49 | } | ||
| 50 | |||
| 51 | static int __init setup_early_printk(char *buf) | 39 | static int __init setup_early_printk(char *buf) |
| 52 | { | 40 | { |
| 53 | register_console(&early_console); | 41 | early_console = &early_console_dev; |
| 42 | register_console(&early_console_dev); | ||
| 54 | return 0; | 43 | return 0; |
| 55 | } | 44 | } |
| 56 | 45 | ||
diff --git a/arch/blackfin/kernel/early_printk.c b/arch/blackfin/kernel/early_printk.c index 84ed8375113c..61fbd2de993d 100644 --- a/arch/blackfin/kernel/early_printk.c +++ b/arch/blackfin/kernel/early_printk.c | |||
| @@ -25,8 +25,6 @@ extern struct console *bfin_earlyserial_init(unsigned int port, | |||
| 25 | extern struct console *bfin_jc_early_init(void); | 25 | extern struct console *bfin_jc_early_init(void); |
| 26 | #endif | 26 | #endif |
| 27 | 27 | ||
| 28 | static struct console *early_console; | ||
| 29 | |||
| 30 | /* Default console */ | 28 | /* Default console */ |
| 31 | #define DEFAULT_PORT 0 | 29 | #define DEFAULT_PORT 0 |
| 32 | #define DEFAULT_CFLAG CS8|B57600 | 30 | #define DEFAULT_CFLAG CS8|B57600 |
diff --git a/arch/microblaze/kernel/early_printk.c b/arch/microblaze/kernel/early_printk.c index 60dcacc68038..365f2d53f1b2 100644 --- a/arch/microblaze/kernel/early_printk.c +++ b/arch/microblaze/kernel/early_printk.c | |||
| @@ -21,7 +21,6 @@ | |||
| 21 | #include <asm/setup.h> | 21 | #include <asm/setup.h> |
| 22 | #include <asm/prom.h> | 22 | #include <asm/prom.h> |
| 23 | 23 | ||
| 24 | static u32 early_console_initialized; | ||
| 25 | static u32 base_addr; | 24 | static u32 base_addr; |
| 26 | 25 | ||
| 27 | #ifdef CONFIG_SERIAL_UARTLITE_CONSOLE | 26 | #ifdef CONFIG_SERIAL_UARTLITE_CONSOLE |
| @@ -109,27 +108,11 @@ static struct console early_serial_uart16550_console = { | |||
| 109 | }; | 108 | }; |
| 110 | #endif /* CONFIG_SERIAL_8250_CONSOLE */ | 109 | #endif /* CONFIG_SERIAL_8250_CONSOLE */ |
| 111 | 110 | ||
| 112 | static struct console *early_console; | ||
| 113 | |||
| 114 | void early_printk(const char *fmt, ...) | ||
| 115 | { | ||
| 116 | char buf[512]; | ||
| 117 | int n; | ||
| 118 | va_list ap; | ||
| 119 | |||
| 120 | if (early_console_initialized) { | ||
| 121 | va_start(ap, fmt); | ||
| 122 | n = vscnprintf(buf, 512, fmt, ap); | ||
| 123 | early_console->write(early_console, buf, n); | ||
| 124 | va_end(ap); | ||
| 125 | } | ||
| 126 | } | ||
| 127 | |||
| 128 | int __init setup_early_printk(char *opt) | 111 | int __init setup_early_printk(char *opt) |
| 129 | { | 112 | { |
| 130 | int version = 0; | 113 | int version = 0; |
| 131 | 114 | ||
| 132 | if (early_console_initialized) | 115 | if (early_console) |
| 133 | return 1; | 116 | return 1; |
| 134 | 117 | ||
| 135 | base_addr = of_early_console(&version); | 118 | base_addr = of_early_console(&version); |
| @@ -159,7 +142,6 @@ int __init setup_early_printk(char *opt) | |||
| 159 | } | 142 | } |
| 160 | 143 | ||
| 161 | register_console(early_console); | 144 | register_console(early_console); |
| 162 | early_console_initialized = 1; | ||
| 163 | return 0; | 145 | return 0; |
| 164 | } | 146 | } |
| 165 | return 1; | 147 | return 1; |
| @@ -169,7 +151,7 @@ int __init setup_early_printk(char *opt) | |||
| 169 | * only for early console because of performance degression */ | 151 | * only for early console because of performance degression */ |
| 170 | void __init remap_early_printk(void) | 152 | void __init remap_early_printk(void) |
| 171 | { | 153 | { |
| 172 | if (!early_console_initialized || !early_console) | 154 | if (!early_console) |
| 173 | return; | 155 | return; |
| 174 | pr_info("early_printk_console remapping from 0x%x to ", base_addr); | 156 | pr_info("early_printk_console remapping from 0x%x to ", base_addr); |
| 175 | base_addr = (u32) ioremap(base_addr, PAGE_SIZE); | 157 | base_addr = (u32) ioremap(base_addr, PAGE_SIZE); |
| @@ -194,9 +176,9 @@ void __init remap_early_printk(void) | |||
| 194 | 176 | ||
| 195 | void __init disable_early_printk(void) | 177 | void __init disable_early_printk(void) |
| 196 | { | 178 | { |
| 197 | if (!early_console_initialized || !early_console) | 179 | if (!early_console) |
| 198 | return; | 180 | return; |
| 199 | pr_warn("disabling early console\n"); | 181 | pr_warn("disabling early console\n"); |
| 200 | unregister_console(early_console); | 182 | unregister_console(early_console); |
| 201 | early_console_initialized = 0; | 183 | early_console = NULL; |
| 202 | } | 184 | } |
diff --git a/arch/mips/kernel/early_printk.c b/arch/mips/kernel/early_printk.c index 9e6440eaa455..505cb77d1280 100644 --- a/arch/mips/kernel/early_printk.c +++ b/arch/mips/kernel/early_printk.c | |||
| @@ -7,7 +7,9 @@ | |||
| 7 | * Copyright (C) 2007 MIPS Technologies, Inc. | 7 | * Copyright (C) 2007 MIPS Technologies, Inc. |
| 8 | * written by Ralf Baechle (ralf@linux-mips.org) | 8 | * written by Ralf Baechle (ralf@linux-mips.org) |
| 9 | */ | 9 | */ |
| 10 | #include <linux/kernel.h> | ||
| 10 | #include <linux/console.h> | 11 | #include <linux/console.h> |
| 12 | #include <linux/printk.h> | ||
| 11 | #include <linux/init.h> | 13 | #include <linux/init.h> |
| 12 | 14 | ||
| 13 | #include <asm/setup.h> | 15 | #include <asm/setup.h> |
| @@ -24,20 +26,18 @@ static void early_console_write(struct console *con, const char *s, unsigned n) | |||
| 24 | } | 26 | } |
| 25 | } | 27 | } |
| 26 | 28 | ||
| 27 | static struct console early_console = { | 29 | static struct console early_console_prom = { |
| 28 | .name = "early", | 30 | .name = "early", |
| 29 | .write = early_console_write, | 31 | .write = early_console_write, |
| 30 | .flags = CON_PRINTBUFFER | CON_BOOT, | 32 | .flags = CON_PRINTBUFFER | CON_BOOT, |
| 31 | .index = -1 | 33 | .index = -1 |
| 32 | }; | 34 | }; |
| 33 | 35 | ||
| 34 | static int early_console_initialized __initdata; | ||
| 35 | |||
| 36 | void __init setup_early_printk(void) | 36 | void __init setup_early_printk(void) |
| 37 | { | 37 | { |
| 38 | if (early_console_initialized) | ||
