|
232 | 232 | /* IMX lpuart has four extra unused regs located at the beginning */
|
233 | 233 | #define IMX_REG_OFF 0x10
|
234 | 234 |
|
| 235 | +static DEFINE_IDA(fsl_lpuart_ida); |
| 236 | + |
235 | 237 | struct lpuart_port {
|
236 | 238 | struct uart_port port;
|
237 | 239 | struct clk *clk;
|
@@ -2143,8 +2145,11 @@ static int lpuart_probe(struct platform_device *pdev)
|
2143 | 2145 |
|
2144 | 2146 | ret = of_alias_get_id(np, "serial");
|
2145 | 2147 | 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 | + } |
2148 | 2153 | }
|
2149 | 2154 | if (ret >= ARRAY_SIZE(lpuart_ports)) {
|
2150 | 2155 | dev_err(&pdev->dev, "serial%d out of range\n", ret);
|
@@ -2246,6 +2251,8 @@ static int lpuart_remove(struct platform_device *pdev)
|
2246 | 2251 |
|
2247 | 2252 | uart_remove_one_port(&lpuart_reg, &sport->port);
|
2248 | 2253 |
|
| 2254 | + ida_simple_remove(&fsl_lpuart_ida, sport->port.line); |
| 2255 | + |
2249 | 2256 | clk_disable_unprepare(sport->clk);
|
2250 | 2257 |
|
2251 | 2258 | if (sport->dma_tx_chan)
|
@@ -2384,6 +2391,7 @@ static int __init lpuart_serial_init(void)
|
2384 | 2391 |
|
2385 | 2392 | static void __exit lpuart_serial_exit(void)
|
2386 | 2393 | {
|
| 2394 | + ida_destroy(&fsl_lpuart_ida); |
2387 | 2395 | platform_driver_unregister(&lpuart_driver);
|
2388 | 2396 | uart_unregister_driver(&lpuart_reg);
|
2389 | 2397 | }
|
|
0 commit comments