serial: tty: uartlite: fix console setup
Subsystems (2)
PATCH 1/1 serial: tty: uartlite: fix console setup
Remove the hack to assign the global console_port variable at probe time. This assumption that cons->index is -1 is wrong for systems that specify 'console=' in the cmdline (or 'stdout-path' in dts). Hence, on such system the actual console assignment is ignored, and the first UART that happens to be probed is used as console instead.
Move the logic to console_setup() and map the console to the correct port through the array of available ports instead.
Signed-off-by Daniel Mack <[email protected]>
--- drivers/tty/serial/uartlite.c | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-)
drivers/tty/serial/uartlite.c +6 -21
@@ -505,21 +505,23 @@ static void ulite_console_write(struct console *co, const char *s,static int ulite_console_setup (struct console *co,char *options) { -struct uart_port *port; +struct uart_port *port =NULL ;int baud =9600 ;int bits =8 ;int parity ='n' ;int flow ='n' ; - - port = console_port; +if (co->index >=0 && co->index <ULITE_NR_UARTS ) + port = ulite_ports + co->index;/* Has the device been initialized yet? */ -if (!port->mapbase) { +if (!port || !port->mapbase) {pr_debug ("console on ttyUL%i not present\n" , co->index);return -ENODEV ; } + console_port = port; +/* not initialized yet? */ if (!port->membase) {if (ulite_request_port (port))
@@ -655,17 +657,6 @@ static int ulite_assign(struct device *dev, int id, u32 base, int irq,dev_set_drvdata (dev, port); -#ifdef CONFIG_SERIAL_UARTLITE_CONSOLE -/* -* If console hasn't been found yet try to assign this port -* because it is required to be assigned for console setup function. -* If register_console() don't assign value, then console_port pointer -* is cleanup. -*/ -if (ulite_uart_driver.cons->index ==-1 ) - console_port = port; -#endif -/* Register the port */ rc =uart_add_one_port (&ulite_uart_driver, port);if (rc) {
@@ -675,12 +666,6 @@ static int ulite_assign(struct device *dev, int id, u32 base, int irq,return rc; } -#ifdef CONFIG_SERIAL_UARTLITE_CONSOLE -/* This is not port which is used for console that's why clean it up */ -if (ulite_uart_driver.cons->index ==-1 ) - console_port =NULL ; -#endif -return 0 ; }
Signature · 1 line
2.31.1