[ARM] Fix AMBA serial drivers for non-first serial ports
authorRussell King <rmk@dyn-67.arm.linux.org.uk>
Mon, 22 Jan 2007 18:59:42 +0000 (18:59 +0000)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Wed, 24 Jan 2007 11:59:57 +0000 (11:59 +0000)
Using console=ttyAM1 or console=ttyAMA1 resulted in an oops during
boot due to trying to drive the console before that port had been
registered.  Fix this by checking whether the port is present before
allowing console setup to proceed.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
drivers/serial/amba-pl010.c
drivers/serial/amba-pl011.c

index 61db6973755a4ee76eed9f27cac40ced59814c20..f69bd097166e96a1956f2c5394ce91da82eaa7cb 100644 (file)
@@ -589,6 +589,8 @@ static int __init pl010_console_setup(struct console *co, char *options)
         */
        if (co->index >= UART_NR)
                co->index = 0;
+       if (!amba_ports[co->index])
+               return -ENODEV;
        port = &amba_ports[co->index]->port;
 
        if (options)
index 9a3b374b2a08d89399b91d75cd613351b83978bf..44639e71372a7eb08c209562e95374fe5d0fb22e 100644 (file)
@@ -661,6 +661,8 @@ static int __init pl011_console_setup(struct console *co, char *options)
        if (co->index >= UART_NR)
                co->index = 0;
        uap = amba_ports[co->index];
+       if (!uap)
+               return -ENODEV;
 
        uap->port.uartclk = clk_get_rate(uap->clk);