serial: sh-sci: Kill off the special earlyprintk device.
This reworks some of the code a bit so that we always wrap in to the
global port array instead of flipping between it and the special early
device. This will make it easier to split the initialization in to early
and late parts where we can simply initialize the remaining bits of the
partially-initialized port coming off of the early console later in the
boot process.
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
diff --git a/drivers/serial/sh-sci.c b/drivers/serial/sh-sci.c
index abf144e..0257fd5 100644
--- a/drivers/serial/sh-sci.c
+++ b/drivers/serial/sh-sci.c
@@ -1781,13 +1781,6 @@
}
#ifdef CONFIG_SERIAL_SH_SCI_CONSOLE
-static struct tty_driver *serial_console_device(struct console *co, int *index)
-{
- struct uart_driver *p = &sci_uart_driver;
- *index = co->index;
- return p->tty_driver;
-}
-
static void serial_console_putchar(struct uart_port *port, int ch)
{
sci_poll_put_char(port, ch);
@@ -1800,8 +1793,8 @@
static void serial_console_write(struct console *co, const char *s,
unsigned count)
{
- struct uart_port *port = co->data;
- struct sci_port *sci_port = to_sci_port(port);
+ struct sci_port *sci_port = &sci_ports[co->index];
+ struct uart_port *port = &sci_port->port;
unsigned short bits;
if (sci_port->enable)
@@ -1829,31 +1822,14 @@
int ret;
/*
- * Check whether an invalid uart number has been specified, and
- * if so, search for the first available port that does have
- * console support.
+ * Refuse to handle any bogus ports.
*/
- if (co->index >= SCI_NPORTS)
- co->index = 0;
-
- if (co->data) {
- port = co->data;
- sci_port = to_sci_port(port);
- } else {
- sci_port = &sci_ports[co->index];
- port = &sci_port->port;
- co->data = port;
- }
-
- /*
- * Also need to check port->type, we don't actually have any
- * UPIO_PORT ports, but uart_report_port() handily misreports
- * it anyways if we don't have a port available by the time this is
- * called.
- */
- if (!port->type)
+ if (co->index < 0 || co->index >= SCI_NPORTS)
return -ENODEV;
+ sci_port = &sci_ports[co->index];
+ port = &sci_port->port;
+
ret = sci_remap_port(port);
if (unlikely(ret != 0))
return ret;
@@ -1876,11 +1852,12 @@
static struct console serial_console = {
.name = "ttySC",
- .device = serial_console_device,
+ .device = uart_console_device,
.write = serial_console_write,
.setup = serial_console_setup,
.flags = CON_PRINTBUFFER,
.index = -1,
+ .data = &sci_uart_driver,
};
static int __init sci_console_init(void)
@@ -1890,12 +1867,11 @@
}
console_initcall(sci_console_init);
-static struct sci_port early_serial_port;
-
static struct console early_serial_console = {
.name = "early_ttySC",
.write = serial_console_write,
.flags = CON_PRINTBUFFER,
+ .index = -1,
};
static char early_serial_buf[32];
@@ -1908,9 +1884,8 @@
return -EEXIST;
early_serial_console.index = pdev->id;
- early_serial_console.data = &early_serial_port.port;
- sci_init_single(NULL, &early_serial_port, pdev->id, cfg);
+ sci_init_single(NULL, &sci_ports[pdev->id], pdev->id, cfg);
serial_console_setup(&early_serial_console, early_serial_buf);
@@ -2001,7 +1976,7 @@
platform_set_drvdata(dev, sp);
- ret = sci_probe_single(dev, dev->id, p, &sci_ports[dev->id]);
+ ret = sci_probe_single(dev, dev->id, p, sp);
if (ret)
goto err_unreg;