Skip to content

Commit

Permalink
serial: sh-sci: Kill off the special earlyprintk device.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Paul Mundt committed Jan 21, 2011
1 parent 1020520 commit 906b17d
Showing 1 changed file with 12 additions and 37 deletions.
49 changes: 12 additions & 37 deletions drivers/serial/sh-sci.c
Original file line number Diff line number Diff line change
Expand Up @@ -1781,13 +1781,6 @@ static int __devinit sci_init_single(struct platform_device *dev,
}

#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);
Expand All @@ -1800,8 +1793,8 @@ static void serial_console_putchar(struct uart_port *port, int ch)
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)
Expand Down Expand Up @@ -1829,31 +1822,14 @@ static int __devinit serial_console_setup(struct console *co, char *options)
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.
*/
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.
* Refuse to handle any bogus ports.
*/
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;
Expand All @@ -1876,11 +1852,12 @@ static int __devinit serial_console_setup(struct console *co, char *options)

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)
Expand All @@ -1890,12 +1867,11 @@ static int __init sci_console_init(void)
}
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];
Expand All @@ -1908,9 +1884,8 @@ static int __devinit sci_probe_earlyprintk(struct platform_device *pdev)
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);

Expand Down Expand Up @@ -2001,7 +1976,7 @@ static int __devinit sci_probe(struct platform_device *dev)

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;

Expand Down

0 comments on commit 906b17d

Please sign in to comment.