Skip to content

Commit 5e9bd2d

Browse files
Michal Simekgregkh
authored andcommitted
serial: uartps: Fix uartps_major handling
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: ab26266 ("serial: uartps: Use the same dynamic major number for all ports") Reported-by: Paul Thomas <[email protected]> Cc: stable <[email protected]> Signed-off-by: Michal Simek <[email protected]> Link: https://lore.kernel.org/r/d2652cda992833315c4f96f06953eb547f928918.1570194248.git.michal.simek@xilinx.com Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent a553add commit 5e9bd2d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

drivers/tty/serial/xilinx_uartps.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1550,7 +1550,6 @@ static int cdns_uart_probe(struct platform_device *pdev)
15501550
goto err_out_id;
15511551
}
15521552

1553-
uartps_major = cdns_uart_uart_driver->tty_driver->major;
15541553
cdns_uart_data->cdns_uart_driver = cdns_uart_uart_driver;
15551554

15561555
/*
@@ -1680,6 +1679,7 @@ static int cdns_uart_probe(struct platform_device *pdev)
16801679
console_port = NULL;
16811680
#endif
16821681

1682+
uartps_major = cdns_uart_uart_driver->tty_driver->major;
16831683
cdns_uart_data->cts_override = of_property_read_bool(pdev->dev.of_node,
16841684
"cts-override");
16851685
return 0;
@@ -1741,6 +1741,12 @@ static int cdns_uart_remove(struct platform_device *pdev)
17411741
console_port = NULL;
17421742
#endif
17431743

1744+
/* If this is last instance major number should be initialized */
1745+
mutex_lock(&bitmap_lock);
1746+
if (bitmap_empty(bitmap, MAX_UART_INSTANCES))
1747+
uartps_major = 0;
1748+
mutex_unlock(&bitmap_lock);
1749+
17441750
uart_unregister_driver(cdns_uart_data->cdns_uart_driver);
17451751
return rc;
17461752
}

0 commit comments

Comments
 (0)