| From 40d71aef75ebc8708fde96c873feb5a9aaf53227 Mon Sep 17 00:00:00 2001 |
| From: Michal Simek <michal.simek@xilinx.com> |
| Date: Fri, 4 Oct 2019 15:04:11 +0200 |
| Subject: [PATCH] serial: uartps: Fix uartps_major handling |
| |
| commit 5e9bd2d70ae7c00a95a22994abf1eef728649e64 upstream. |
| |
| There are two parts which should be fixed. The first one is to assigned |
| uartps_major at the end of probe() to avoid complicated logic when |
| something fails. |
| The second part is initialized uartps_major number to 0 when last device is |
| removed. This will ensure that on next probe driver will ask for new |
| dynamic major number. |
| |
| Fixes: ab262666018d ("serial: uartps: Use the same dynamic major number for all ports") |
| Reported-by: Paul Thomas <pthomas8589@gmail.com> |
| Cc: stable <stable@vger.kernel.org> |
| Signed-off-by: Michal Simek <michal.simek@xilinx.com> |
| Link: https://lore.kernel.org/r/d2652cda992833315c4f96f06953eb547f928918.1570194248.git.michal.simek@xilinx.com |
| Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
| Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com> |
| |
| diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c |
| index 9dcc4d855ddd..efd54a010243 100644 |
| --- a/drivers/tty/serial/xilinx_uartps.c |
| +++ b/drivers/tty/serial/xilinx_uartps.c |
| @@ -1546,7 +1546,6 @@ static int cdns_uart_probe(struct platform_device *pdev) |
| goto err_out_id; |
| } |
| |
| - uartps_major = cdns_uart_uart_driver->tty_driver->major; |
| cdns_uart_data->cdns_uart_driver = cdns_uart_uart_driver; |
| |
| /* |
| @@ -1676,6 +1675,7 @@ static int cdns_uart_probe(struct platform_device *pdev) |
| console_port = NULL; |
| #endif |
| |
| + uartps_major = cdns_uart_uart_driver->tty_driver->major; |
| cdns_uart_data->cts_override = of_property_read_bool(pdev->dev.of_node, |
| "cts-override"); |
| return 0; |
| @@ -1737,6 +1737,12 @@ static int cdns_uart_remove(struct platform_device *pdev) |
| console_port = NULL; |
| #endif |
| |
| + /* If this is last instance major number should be initialized */ |
| + mutex_lock(&bitmap_lock); |
| + if (bitmap_empty(bitmap, MAX_UART_INSTANCES)) |
| + uartps_major = 0; |
| + mutex_unlock(&bitmap_lock); |
| + |
| uart_unregister_driver(cdns_uart_data->cdns_uart_driver); |
| return rc; |
| } |
| -- |
| 2.7.4 |
| |