diff options
author | Yuan Yao <yao.yuan@nxp.com> | 2016-12-14 08:33:32 (GMT) |
---|---|---|
committer | Xie Xiaobo <xiaobo.xie@nxp.com> | 2017-09-25 07:25:38 (GMT) |
commit | 96a3982cb8511a2f9d11b0436712ba134df8bb61 (patch) | |
tree | d0462a9478aa846835c16da1622278dd85062a74 | |
parent | 4ca79a9024ccce543d07c173f15bbacb40175e9d (diff) | |
download | linux-96a3982cb8511a2f9d11b0436712ba134df8bb61.tar.xz |
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: Yuan Yao <yao.yuan@nxp.com>
Signed-off-by: Sriram Dash <Sriram.dash@nxp.com>
-rw-r--r-- | drivers/tty/serial/fsl_lpuart.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c index 96104ac..6145382 100644 --- a/drivers/tty/serial/fsl_lpuart.c +++ b/drivers/tty/serial/fsl_lpuart.c @@ -231,6 +231,8 @@ #define DEV_NAME "ttyLP" #define UART_NR 6 +static DECLARE_BITMAP(linemap, UART_NR); + struct lpuart_port { struct uart_port port; struct clk *clk; @@ -1920,9 +1922,13 @@ static int lpuart_probe(struct platform_device *pdev) ret = of_alias_get_id(np, "serial"); if (ret < 0) { - dev_err(&pdev->dev, "failed to get alias id, errno %d\n", ret); - return ret; + ret = find_first_zero_bit(linemap, UART_NR); + if (ret >= UART_NR) { + dev_err(&pdev->dev, "port line is full, add device failed\n"); + return ret; + } } + set_bit(ret, linemap); sport->port.line = ret; sport->lpuart32 = of_device_is_compatible(np, "fsl,ls1021a-lpuart"); @@ -2004,6 +2010,7 @@ static int lpuart_remove(struct platform_device *pdev) struct lpuart_port *sport = platform_get_drvdata(pdev); uart_remove_one_port(&lpuart_reg, &sport->port); + clear_bit(sport->port.line, linemap); clk_disable_unprepare(sport->clk); |