[PATCH v2] serial: fsl_lpuart: Remove the alias node dependence

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: vabhav <vabhav.sharma@xxxxxxx>

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.

v2:
  Incorporated Review comments https://patchwork.kernel.org/patch/9473977/

Signed-off-by: Yuan Yao <yao.yuan@xxxxxxx>
Signed-off-by: vabhav <vabhav.sharma@xxxxxxx>
---
 drivers/tty/serial/fsl_lpuart.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
index 51e47a6..00f06eb 100644
--- a/drivers/tty/serial/fsl_lpuart.c
+++ b/drivers/tty/serial/fsl_lpuart.c
@@ -232,6 +232,8 @@
 /* IMX lpuart has four extra unused regs located at the beginning */
 #define IMX_REG_OFF	0x10
 
+static DEFINE_IDA(fsl_lpuart_ida);
+
 struct lpuart_port {
 	struct uart_port	port;
 	struct clk		*clk;
@@ -2142,8 +2144,11 @@ 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 = ida_simple_get(&fsl_lpuart_ida, 0, UART_NR, GFP_KERNEL);
+		if (ret < 0) {
+			dev_err(&pdev->dev, "port line is full, add device failed\n");
+			return ret;
+		}
 	}
 	if (ret >= ARRAY_SIZE(lpuart_ports)) {
 		dev_err(&pdev->dev, "serial%d out of range\n", ret);
@@ -2245,6 +2250,8 @@ static int lpuart_remove(struct platform_device *pdev)
 
 	uart_remove_one_port(&lpuart_reg, &sport->port);
 
+	ida_simple_remove(&fsl_lpuart_ida, sport->port.line);
+
 	clk_disable_unprepare(sport->clk);
 
 	if (sport->dma_tx_chan)
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux