aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichal Simek <michal.simek@xilinx.com>2018-04-23 05:51:01 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-04-25 08:58:45 -0400
commit0413fe045dda45781cb33788c2d57eafdf8295f7 (patch)
treefad042b997e033d4aaddaf9da606766e84e829c2
parent0f38c5e3e0ade98b49e2c7ca5550ee9e36cbc04f (diff)
serial: uartps: Use dynamic array for console port
Driver console functions are using pointer to static array with fixed size. There can be only one serial console at the time which is found by register_console(). register_console() is filling cons->index to port->line value. Signed-off-by: Michal Simek <michal.simek@xilinx.com> Reviewed-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/tty/serial/xilinx_uartps.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c
index 04fc10603855..5bde59342f8f 100644
--- a/drivers/tty/serial/xilinx_uartps.c
+++ b/drivers/tty/serial/xilinx_uartps.c
@@ -1206,6 +1206,10 @@ OF_EARLYCON_DECLARE(cdns, "cdns,uart-r1p8", cdns_early_console_setup);
1206OF_EARLYCON_DECLARE(cdns, "cdns,uart-r1p12", cdns_early_console_setup); 1206OF_EARLYCON_DECLARE(cdns, "cdns,uart-r1p12", cdns_early_console_setup);
1207OF_EARLYCON_DECLARE(cdns, "xlnx,zynqmp-uart", cdns_early_console_setup); 1207OF_EARLYCON_DECLARE(cdns, "xlnx,zynqmp-uart", cdns_early_console_setup);
1208 1208
1209
1210/* Static pointer to console port */
1211static struct uart_port *console_port;
1212
1209/** 1213/**
1210 * cdns_uart_console_write - perform write operation 1214 * cdns_uart_console_write - perform write operation
1211 * @co: Console handle 1215 * @co: Console handle
@@ -1215,7 +1219,7 @@ OF_EARLYCON_DECLARE(cdns, "xlnx,zynqmp-uart", cdns_early_console_setup);
1215static void cdns_uart_console_write(struct console *co, const char *s, 1219static void cdns_uart_console_write(struct console *co, const char *s,
1216 unsigned int count) 1220 unsigned int count)
1217{ 1221{
1218 struct uart_port *port = &cdns_uart_port[co->index]; 1222 struct uart_port *port = console_port;
1219 unsigned long flags; 1223 unsigned long flags;
1220 unsigned int imr, ctrl; 1224 unsigned int imr, ctrl;
1221 int locked = 1; 1225 int locked = 1;
@@ -1261,15 +1265,13 @@ static void cdns_uart_console_write(struct console *co, const char *s,
1261 */ 1265 */
1262static int __init cdns_uart_console_setup(struct console *co, char *options) 1266static int __init cdns_uart_console_setup(struct console *co, char *options)
1263{ 1267{
1264 struct uart_port *port = &cdns_uart_port[co->index]; 1268 struct uart_port *port = console_port;
1269
1265 int baud = 9600; 1270 int baud = 9600;
1266 int bits = 8; 1271 int bits = 8;
1267 int parity = 'n'; 1272 int parity = 'n';
1268 int flow = 'n'; 1273 int flow = 'n';
1269 1274
1270 if (co->index < 0 || co->index >= CDNS_UART_NR_PORTS)
1271 return -EINVAL;
1272
1273 if (!port->membase) { 1275 if (!port->membase) {
1274 pr_debug("console on " CDNS_UART_TTY_NAME "%i not present\n", 1276 pr_debug("console on " CDNS_UART_TTY_NAME "%i not present\n",
1275 co->index); 1277 co->index);
@@ -1563,6 +1565,17 @@ static int cdns_uart_probe(struct platform_device *pdev)
1563 pm_runtime_set_active(&pdev->dev); 1565 pm_runtime_set_active(&pdev->dev);
1564 pm_runtime_enable(&pdev->dev); 1566 pm_runtime_enable(&pdev->dev);
1565 1567
1568#ifdef CONFIG_SERIAL_XILINX_PS_UART_CONSOLE
1569 /*
1570 * If console hasn't been found yet try to assign this port
1571 * because it is required to be assigned for console setup function.
1572 * If register_console() don't assign value, then console_port pointer
1573 * is cleanup.
1574 */
1575 if (cdns_uart_uart_driver.cons->index == -1)
1576 console_port = port;
1577#endif
1578
1566 rc = uart_add_one_port(&cdns_uart_uart_driver, port); 1579 rc = uart_add_one_port(&cdns_uart_uart_driver, port);
1567 if (rc) { 1580 if (rc) {
1568 dev_err(&pdev->dev, 1581 dev_err(&pdev->dev,
@@ -1570,6 +1583,12 @@ static int cdns_uart_probe(struct platform_device *pdev)
1570 goto err_out_pm_disable; 1583 goto err_out_pm_disable;
1571 } 1584 }
1572 1585
1586#ifdef CONFIG_SERIAL_XILINX_PS_UART_CONSOLE
1587 /* This is not port which is used for console that's why clean it up */
1588 if (cdns_uart_uart_driver.cons->index == -1)
1589 console_port = NULL;
1590#endif
1591
1573 return 0; 1592 return 0;
1574 1593
1575err_out_pm_disable: 1594err_out_pm_disable: