Skip to content

Commit 3bc3206

Browse files
vabhavnxpgregkh
authored andcommitted
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 <[email protected]> Signed-off-by: Vabhav Sharma <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 4e1a606 commit 3bc3206

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

drivers/tty/serial/fsl_lpuart.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,8 @@
232232
/* IMX lpuart has four extra unused regs located at the beginning */
233233
#define IMX_REG_OFF 0x10
234234

235+
static DEFINE_IDA(fsl_lpuart_ida);
236+
235237
struct lpuart_port {
236238
struct uart_port port;
237239
struct clk *clk;
@@ -2143,8 +2145,11 @@ static int lpuart_probe(struct platform_device *pdev)
21432145

21442146
ret = of_alias_get_id(np, "serial");
21452147
if (ret < 0) {
2146-
dev_err(&pdev->dev, "failed to get alias id, errno %d\n", ret);
2147-
return ret;
2148+
ret = ida_simple_get(&fsl_lpuart_ida, 0, UART_NR, GFP_KERNEL);
2149+
if (ret < 0) {
2150+
dev_err(&pdev->dev, "port line is full, add device failed\n");
2151+
return ret;
2152+
}
21482153
}
21492154
if (ret >= ARRAY_SIZE(lpuart_ports)) {
21502155
dev_err(&pdev->dev, "serial%d out of range\n", ret);
@@ -2246,6 +2251,8 @@ static int lpuart_remove(struct platform_device *pdev)
22462251

22472252
uart_remove_one_port(&lpuart_reg, &sport->port);
22482253

2254+
ida_simple_remove(&fsl_lpuart_ida, sport->port.line);
2255+
22492256
clk_disable_unprepare(sport->clk);
22502257

22512258
if (sport->dma_tx_chan)
@@ -2384,6 +2391,7 @@ static int __init lpuart_serial_init(void)
23842391

23852392
static void __exit lpuart_serial_exit(void)
23862393
{
2394+
ida_destroy(&fsl_lpuart_ida);
23872395
platform_driver_unregister(&lpuart_driver);
23882396
uart_unregister_driver(&lpuart_reg);
23892397
}

0 commit comments

Comments
 (0)