diff options
-rw-r--r-- | drivers/serial/sh-sci.c | 49 |
1 files changed, 12 insertions, 37 deletions
diff --git a/drivers/serial/sh-sci.c b/drivers/serial/sh-sci.c index abf144eed072..0257fd5ede52 100644 --- a/drivers/serial/sh-sci.c +++ b/drivers/serial/sh-sci.c | |||
@@ -1781,13 +1781,6 @@ static int __devinit sci_init_single(struct platform_device *dev, | |||
1781 | } | 1781 | } |
1782 | 1782 | ||
1783 | #ifdef CONFIG_SERIAL_SH_SCI_CONSOLE | 1783 | #ifdef CONFIG_SERIAL_SH_SCI_CONSOLE |
1784 | static struct tty_driver *serial_console_device(struct console *co, int *index) | ||
1785 | { | ||
1786 | struct uart_driver *p = &sci_uart_driver; | ||
1787 | *index = co->index; | ||
1788 | return p->tty_driver; | ||
1789 | } | ||
1790 | |||
1791 | static void serial_console_putchar(struct uart_port *port, int ch) | 1784 | static void serial_console_putchar(struct uart_port *port, int ch) |
1792 | { | 1785 | { |
1793 | sci_poll_put_char(port, ch); | 1786 | sci_poll_put_char(port, ch); |
@@ -1800,8 +1793,8 @@ static void serial_console_putchar(struct uart_port *port, int ch) | |||
1800 | static void serial_console_write(struct console *co, const char *s, | 1793 | static void serial_console_write(struct console *co, const char *s, |
1801 | unsigned count) | 1794 | unsigned count) |
1802 | { | 1795 | { |
1803 | struct uart_port *port = co->data; | 1796 | struct sci_port *sci_port = &sci_ports[co->index]; |
1804 | struct sci_port *sci_port = to_sci_port(port); | 1797 | struct uart_port *port = &sci_port->port; |
1805 | unsigned short bits; | 1798 | unsigned short bits; |
1806 | 1799 | ||
1807 | if (sci_port->enable) | 1800 | if (sci_port->enable) |
@@ -1829,31 +1822,14 @@ static int __devinit serial_console_setup(struct console *co, char *options) | |||
1829 | int ret; | 1822 | int ret; |
1830 | 1823 | ||
1831 | /* | 1824 | /* |
1832 | * Check whether an invalid uart number has been specified, and | 1825 | * Refuse to handle any bogus ports. |
1833 | * if so, search for the first available port that does have | ||
1834 | * console support. | ||
1835 | */ | ||
1836 | if (co->index >= SCI_NPORTS) | ||
1837 | co->index = 0; | ||
1838 | |||
1839 | if (co->data) { | ||
1840 | port = co->data; | ||
1841 | sci_port = to_sci_port(port); | ||
1842 | } else { | ||
1843 | sci_port = &sci_ports[co->index]; | ||
1844 | port = &sci_port->port; | ||
1845 | co->data = port; | ||
1846 | } | ||
1847 | |||
1848 | /* | ||
1849 | * Also need to check port->type, we don't actually have any | ||
1850 | * UPIO_PORT ports, but uart_report_port() handily misreports | ||
1851 | * it anyways if we don't have a port available by the time this is | ||
1852 | * called. | ||
1853 | */ | 1826 | */ |
1854 | if (!port->type) | 1827 | if (co->index < 0 || co->index >= SCI_NPORTS) |
1855 | return -ENODEV; | 1828 | return -ENODEV; |
1856 | 1829 | ||
1830 | sci_port = &sci_ports[co->index]; | ||
1831 | port = &sci_port->port; | ||
1832 | |||
1857 | ret = sci_remap_port(port); | 1833 | ret = sci_remap_port(port); |
1858 | if (unlikely(ret != 0)) | 1834 | if (unlikely(ret != 0)) |
1859 | return ret; | 1835 | return ret; |
@@ -1876,11 +1852,12 @@ static int __devinit serial_console_setup(struct console *co, char *options) | |||
1876 | 1852 | ||
1877 | static struct console serial_console = { | 1853 | static struct console serial_console = { |
1878 | .name = "ttySC", | 1854 | .name = "ttySC", |
1879 | .device = serial_console_device, | 1855 | .device = uart_console_device, |
1880 | .write = serial_console_write, | 1856 | .write = serial_console_write, |
1881 | .setup = serial_console_setup, | 1857 | .setup = serial_console_setup, |
1882 | .flags = CON_PRINTBUFFER, | 1858 | .flags = CON_PRINTBUFFER, |
1883 | .index = -1, | 1859 | .index = -1, |
1860 | .data = &sci_uart_driver, | ||
1884 | }; | 1861 | }; |
1885 | 1862 | ||
1886 | static int __init sci_console_init(void) | 1863 | static int __init sci_console_init(void) |
@@ -1890,12 +1867,11 @@ static int __init sci_console_init(void) | |||
1890 | } | 1867 | } |
1891 | console_initcall(sci_console_init); | 1868 | console_initcall(sci_console_init); |
1892 | 1869 | ||
1893 | static struct sci_port early_serial_port; | ||
1894 | |||
1895 | static struct console early_serial_console = { | 1870 | static struct console early_serial_console = { |
1896 | .name = "early_ttySC", | 1871 | .name = "early_ttySC", |
1897 | .write = serial_console_write, | 1872 | .write = serial_console_write, |
1898 | .flags = CON_PRINTBUFFER, | 1873 | .flags = CON_PRINTBUFFER, |
1874 | .index = -1, | ||
1899 | }; | 1875 | }; |
1900 | 1876 | ||
1901 | static char early_serial_buf[32]; | 1877 | static char early_serial_buf[32]; |
@@ -1908,9 +1884,8 @@ static int __devinit sci_probe_earlyprintk(struct platform_device *pdev) | |||
1908 | return -EEXIST; | 1884 | return -EEXIST; |
1909 | 1885 | ||
1910 | early_serial_console.index = pdev->id; | 1886 | early_serial_console.index = pdev->id; |
1911 | early_serial_console.data = &early_serial_port.port; | ||
1912 | 1887 | ||
1913 | sci_init_single(NULL, &early_serial_port, pdev->id, cfg); | 1888 | sci_init_single(NULL, &sci_ports[pdev->id], pdev->id, cfg); |
1914 | 1889 | ||
1915 | serial_console_setup(&early_serial_console, early_serial_buf); | 1890 | serial_console_setup(&early_serial_console, early_serial_buf); |
1916 | 1891 | ||
@@ -2001,7 +1976,7 @@ static int __devinit sci_probe(struct platform_device *dev) | |||
2001 | 1976 | ||
2002 | platform_set_drvdata(dev, sp); | 1977 | platform_set_drvdata(dev, sp); |
2003 | 1978 | ||
2004 | ret = sci_probe_single(dev, dev->id, p, &sci_ports[dev->id]); | 1979 | ret = sci_probe_single(dev, dev->id, p, sp); |
2005 | if (ret) | 1980 | if (ret) |
2006 | goto err_unreg; | 1981 | goto err_unreg; |
2007 | 1982 | ||