aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Mundt <lethal@linux-sh.org>2011-01-20 10:05:48 -0500
committerPaul Mundt <lethal@linux-sh.org>2011-01-20 10:05:48 -0500
commitecdf8a4607edfebbfd6baada8eaecf532bf38600 (patch)
tree78548689f854f197ce49a792206fedd4f34029b8
parentbc9b3f5c9f3702e71066a4de0afe509a201d98b4 (diff)
serial: sh-sci: Limit early console to one device.
Presently the early console setup will be invoked for every device handed off to he earlyprintk command line argument. In practice we can only handle one, so this adds a sanity check to prevent clobbering the existing active console. Signed-off-by: Paul Mundt <lethal@linux-sh.org>
-rw-r--r--drivers/serial/sh-sci.c58
1 files changed, 35 insertions, 23 deletions
diff --git a/drivers/serial/sh-sci.c b/drivers/serial/sh-sci.c
index 999fe5f5d938..7b2760be0260 100644
--- a/drivers/serial/sh-sci.c
+++ b/drivers/serial/sh-sci.c
@@ -1870,13 +1870,40 @@ static int __init sci_console_init(void)
1870console_initcall(sci_console_init); 1870console_initcall(sci_console_init);
1871 1871
1872static struct sci_port early_serial_port; 1872static struct sci_port early_serial_port;
1873
1873static struct console early_serial_console = { 1874static struct console early_serial_console = {
1874 .name = "early_ttySC", 1875 .name = "early_ttySC",
1875 .write = serial_console_write, 1876 .write = serial_console_write,
1876 .flags = CON_PRINTBUFFER, 1877 .flags = CON_PRINTBUFFER,
1877}; 1878};
1879
1878static char early_serial_buf[32]; 1880static char early_serial_buf[32];
1879 1881
1882static int __devinit sci_probe_earlyprintk(struct platform_device *pdev)
1883{
1884 struct plat_sci_port *cfg = pdev->dev.platform_data;
1885
1886 if (early_serial_console.data)
1887 return -EEXIST;
1888
1889 early_serial_console.index = pdev->id;
1890 early_serial_console.data = &early_serial_port.port;
1891
1892 sci_init_single(NULL, &early_serial_port, pdev->id, cfg);
1893
1894 serial_console_setup(&early_serial_console, early_serial_buf);
1895
1896 if (!strstr(early_serial_buf, "keep"))
1897 early_serial_console.flags |= CON_BOOT;
1898
1899 register_console(&early_serial_console);
1900 return 0;
1901}
1902#else
1903static inline int __devinit sci_probe_earlyprintk(struct platform_device *pdev)
1904{
1905 return -EINVAL;
1906}
1880#endif /* CONFIG_SERIAL_SH_SCI_CONSOLE */ 1907#endif /* CONFIG_SERIAL_SH_SCI_CONSOLE */
1881 1908
1882#if defined(CONFIG_SERIAL_SH_SCI_CONSOLE) 1909#if defined(CONFIG_SERIAL_SH_SCI_CONSOLE)
@@ -1937,34 +1964,19 @@ static int __devinit sci_probe_single(struct platform_device *dev,
1937 return uart_add_one_port(&sci_uart_driver, &sciport->port); 1964 return uart_add_one_port(&sci_uart_driver, &sciport->port);
1938} 1965}
1939 1966
1940/*
1941 * Register a set of serial devices attached to a platform device. The
1942 * list is terminated with a zero flags entry, which means we expect
1943 * all entries to have at least UPF_BOOT_AUTOCONF set. Platforms that need
1944 * remapping (such as sh64) should also set UPF_IOREMAP.
1945 */
1946static int __devinit sci_probe(struct platform_device *dev) 1967static int __devinit sci_probe(struct platform_device *dev)
1947{ 1968{
1948 struct plat_sci_port *p = dev->dev.platform_data; 1969 struct plat_sci_port *p = dev->dev.platform_data;
1949 struct sci_port *sp = &sci_ports[dev->id]; 1970 struct sci_port *sp = &sci_ports[dev->id];
1950 int ret = -EINVAL; 1971 int ret;
1951
1952#ifdef CONFIG_SERIAL_SH_SCI_CONSOLE
1953 if (is_early_platform_device(dev)) {
1954 early_serial_console.index = dev->id;
1955 early_serial_console.data = &early_serial_port.port;
1956
1957 sci_init_single(NULL, &early_serial_port, dev->id, p);
1958
1959 serial_console_setup(&early_serial_console, early_serial_buf);
1960
1961 if (!strstr(early_serial_buf, "keep"))
1962 early_serial_console.flags |= CON_BOOT;
1963 1972
1964 register_console(&early_serial_console); 1973 /*
1965 return 0; 1974 * If we've come here via earlyprintk initialization, head off to
1966 } 1975 * the special early probe. We don't have sufficient device state
1967#endif 1976 * to make it beyond this yet.
1977 */
1978 if (is_early_platform_device(dev))
1979 return sci_probe_earlyprintk(dev);
1968 1980
1969 platform_set_drvdata(dev, sp); 1981 platform_set_drvdata(dev, sp);
1970 1982