Commit 99038fe7 authored by Chunyan Zhang's avatar Chunyan Zhang Committed by Greg Kroah-Hartman

serial: sprd: check the right port and membase

When calling sprd_console_setup(), sprd_uart_port probably is NULL,
we should check that first instead of checking its items directly.

Also we should check membase to avoid accessing uart device before
its initialization finished.
Signed-off-by: default avatarChunyan Zhang <chunyan.zhang@unisoc.com>
Signed-off-by: default avatarChunyan Zhang <zhang.lyra@gmail.com>
Reviewed-by: default avatarBaolin Wang <baolin.wang@linaro.org>
Tested-by: default avatarBaolin Wang <baolin.wang@linaro.org>
Link: https://lore.kernel.org/r/20190826072929.7696-2-zhang.lyra@gmail.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent d2d8d4c0
...@@ -983,7 +983,7 @@ static void sprd_console_write(struct console *co, const char *s, ...@@ -983,7 +983,7 @@ static void sprd_console_write(struct console *co, const char *s,
static int __init sprd_console_setup(struct console *co, char *options) static int __init sprd_console_setup(struct console *co, char *options)
{ {
struct uart_port *port; struct sprd_uart_port *sprd_uart_port;
int baud = 115200; int baud = 115200;
int bits = 8; int bits = 8;
int parity = 'n'; int parity = 'n';
...@@ -992,15 +992,17 @@ static int __init sprd_console_setup(struct console *co, char *options) ...@@ -992,15 +992,17 @@ static int __init sprd_console_setup(struct console *co, char *options)
if (co->index >= UART_NR_MAX || co->index < 0) if (co->index >= UART_NR_MAX || co->index < 0)
co->index = 0; co->index = 0;
port = &sprd_port[co->index]->port; sprd_uart_port = sprd_port[co->index];
if (port == NULL) { if (!sprd_uart_port || !sprd_uart_port->port.membase) {
pr_info("serial port %d not yet initialized\n", co->index); pr_info("serial port %d not yet initialized\n", co->index);
return -ENODEV; return -ENODEV;
} }
if (options) if (options)
uart_parse_options(options, &baud, &parity, &bits, &flow); uart_parse_options(options, &baud, &parity, &bits, &flow);
return uart_set_options(port, co, baud, parity, bits, flow); return uart_set_options(&sprd_uart_port->port, co, baud,
parity, bits, flow);
} }
static struct uart_driver sprd_uart_driver; static struct uart_driver sprd_uart_driver;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment