Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d0380e6c authored by Thomas Gleixner's avatar Thomas Gleixner Committed by Linus Torvalds
Browse files

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: default avatarThomas Gleixner <tglx@linutronix.de>
Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
Cc: Russell King <linux@arm.linux.org.uk>
Acked-by: default avatarMike 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: default avatarIngo Molnar <mingo@kernel.org>
Tested-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 07c65f4d
Loading
Loading
Loading
Loading
+3 −14
Original line number Diff line number Diff line
@@ -29,28 +29,17 @@ static void early_console_write(struct console *con, const char *s, unsigned n)
	early_write(s, n);
}

static struct console early_console = {
static struct console early_console_dev = {
	.name =		"earlycon",
	.write =	early_console_write,
	.flags =	CON_PRINTBUFFER | CON_BOOT,
	.index =	-1,
};

asmlinkage void early_printk(const char *fmt, ...)
{
	char buf[512];
	int n;
	va_list ap;

	va_start(ap, fmt);
	n = vscnprintf(buf, sizeof(buf), fmt, ap);
	early_write(buf, n);
	va_end(ap);
}

static int __init setup_early_printk(char *buf)
{
	register_console(&early_console);
	early_console = &early_console_dev;
	register_console(&early_console_dev);
	return 0;
}

+0 −2
Original line number Diff line number Diff line
@@ -25,8 +25,6 @@ extern struct console *bfin_earlyserial_init(unsigned int port,
extern struct console *bfin_jc_early_init(void);
#endif

static struct console *early_console;

/* Default console */
#define DEFAULT_PORT 0
#define DEFAULT_CFLAG CS8|B57600
+4 −22
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@
#include <asm/setup.h>
#include <asm/prom.h>

static u32 early_console_initialized;
static u32 base_addr;

#ifdef CONFIG_SERIAL_UARTLITE_CONSOLE
@@ -109,27 +108,11 @@ static struct console early_serial_uart16550_console = {
};
#endif /* CONFIG_SERIAL_8250_CONSOLE */

static struct console *early_console;

void early_printk(const char *fmt, ...)
{
	char buf[512];
	int n;
	va_list ap;

	if (early_console_initialized) {
		va_start(ap, fmt);
		n = vscnprintf(buf, 512, fmt, ap);
		early_console->write(early_console, buf, n);
		va_end(ap);
	}
}

int __init setup_early_printk(char *opt)
{
	int version = 0;

	if (early_console_initialized)
	if (early_console)
		return 1;

	base_addr = of_early_console(&version);
@@ -159,7 +142,6 @@ int __init setup_early_printk(char *opt)
		}

		register_console(early_console);
		early_console_initialized = 1;
		return 0;
	}
	return 1;
@@ -169,7 +151,7 @@ int __init setup_early_printk(char *opt)
 * only for early console because of performance degression */
void __init remap_early_printk(void)
{
	if (!early_console_initialized || !early_console)
	if (!early_console)
		return;
	pr_info("early_printk_console remapping from 0x%x to ", base_addr);
	base_addr = (u32) ioremap(base_addr, PAGE_SIZE);
@@ -194,9 +176,9 @@ void __init remap_early_printk(void)

void __init disable_early_printk(void)
{
	if (!early_console_initialized || !early_console)
	if (!early_console)
		return;
	pr_warn("disabling early console\n");
	unregister_console(early_console);
	early_console_initialized = 0;
	early_console = NULL;
}
+6 −6
Original line number Diff line number Diff line
@@ -7,7 +7,9 @@
 * Copyright (C) 2007 MIPS Technologies, Inc.
 *   written by Ralf Baechle (ralf@linux-mips.org)
 */
#include <linux/kernel.h>
#include <linux/console.h>
#include <linux/printk.h>
#include <linux/init.h>

#include <asm/setup.h>
@@ -24,20 +26,18 @@ static void early_console_write(struct console *con, const char *s, unsigned n)
	}
}

static struct console early_console = {
static struct console early_console_prom = {
	.name	= "early",
	.write	= early_console_write,
	.flags	= CON_PRINTBUFFER | CON_BOOT,
	.index	= -1
};

static int early_console_initialized __initdata;

void __init setup_early_printk(void)
{
	if (early_console_initialized)
	if (early_console)
		return;
	early_console_initialized = 1;
	early_console = &early_console_prom;

	register_console(&early_console);
	register_console(&early_console_prom);
}
+2 −4
Original line number Diff line number Diff line
@@ -156,15 +156,13 @@ static struct console udbg_console = {
	.index	= 0,
};

static int early_console_initialized;

/*
 * Called by setup_system after ppc_md->probe and ppc_md->early_init.
 * Call it again after setting udbg_putc in ppc_md->setup_arch.
 */
void __init register_early_udbg_console(void)
{
	if (early_console_initialized)
	if (early_console)
		return;

	if (!udbg_putc)
@@ -174,7 +172,7 @@ void __init register_early_udbg_console(void)
		printk(KERN_INFO "early console immortal !\n");
		udbg_console.flags &= ~CON_BOOT;
	}
	early_console_initialized = 1;
	early_console = &udbg_console;
	register_console(&udbg_console);
}

Loading