Commit 3bc3206e authored by Vabhav Sharma's avatar Vabhav Sharma Committed by Greg Kroah-Hartman

serial: fsl_lpuart: Remove the alias node dependence

Numbering the ttyLPn space should not depend on the generic name
"serial<n>".

If don't add the alias node like:"serial0 = &lpuart0;", then lpuart
will probe failed:
[    0.773410] fsl-lpuart 2950000.serial: failed to get alias id, errno -19

So remove the alias node dependence, and add the support for allocate the
line port automatically.
Signed-off-by: default avatarYuan Yao <yao.yuan@nxp.com>
Signed-off-by: default avatarVabhav Sharma <vabhav.sharma@nxp.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 4e1a606d
...@@ -232,6 +232,8 @@ ...@@ -232,6 +232,8 @@
/* IMX lpuart has four extra unused regs located at the beginning */ /* IMX lpuart has four extra unused regs located at the beginning */
#define IMX_REG_OFF 0x10 #define IMX_REG_OFF 0x10
static DEFINE_IDA(fsl_lpuart_ida);
struct lpuart_port { struct lpuart_port {
struct uart_port port; struct uart_port port;
struct clk *clk; struct clk *clk;
...@@ -2143,8 +2145,11 @@ static int lpuart_probe(struct platform_device *pdev) ...@@ -2143,8 +2145,11 @@ static int lpuart_probe(struct platform_device *pdev)
ret = of_alias_get_id(np, "serial"); ret = of_alias_get_id(np, "serial");
if (ret < 0) { if (ret < 0) {
dev_err(&pdev->dev, "failed to get alias id, errno %d\n", ret); ret = ida_simple_get(&fsl_lpuart_ida, 0, UART_NR, GFP_KERNEL);
return ret; if (ret < 0) {
dev_err(&pdev->dev, "port line is full, add device failed\n");
return ret;
}
} }
if (ret >= ARRAY_SIZE(lpuart_ports)) { if (ret >= ARRAY_SIZE(lpuart_ports)) {
dev_err(&pdev->dev, "serial%d out of range\n", ret); dev_err(&pdev->dev, "serial%d out of range\n", ret);
...@@ -2246,6 +2251,8 @@ static int lpuart_remove(struct platform_device *pdev) ...@@ -2246,6 +2251,8 @@ static int lpuart_remove(struct platform_device *pdev)
uart_remove_one_port(&lpuart_reg, &sport->port); uart_remove_one_port(&lpuart_reg, &sport->port);
ida_simple_remove(&fsl_lpuart_ida, sport->port.line);
clk_disable_unprepare(sport->clk); clk_disable_unprepare(sport->clk);
if (sport->dma_tx_chan) if (sport->dma_tx_chan)
...@@ -2384,6 +2391,7 @@ static int __init lpuart_serial_init(void) ...@@ -2384,6 +2391,7 @@ static int __init lpuart_serial_init(void)
static void __exit lpuart_serial_exit(void) static void __exit lpuart_serial_exit(void)
{ {
ida_destroy(&fsl_lpuart_ida);
platform_driver_unregister(&lpuart_driver); platform_driver_unregister(&lpuart_driver);
uart_unregister_driver(&lpuart_reg); uart_unregister_driver(&lpuart_reg);
} }
......
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