Skip to content

Commit 9d7ee0e

Browse files
fugangduangregkh
authored andcommitted
tty: serial: lpuart: avoid report NULL interrupt
The current driver register irq in .startup() and free the irq in .shutdown(), then user will see the NULL interrupt output from 'cat /proc/interrupts' after the uart port test completed: ... 41: 515 0 0 0 GICv3 257 Level fsl-lpuart 42: 2 0 0 0 GICv3 258 Level ... It is better to register all the irqs during probe function via devm_request_irq() to avoid to call free_irq(). Signed-off-by: Fugang Duan <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 0e5ec41 commit 9d7ee0e

File tree

1 file changed

+17
-23
lines changed

1 file changed

+17
-23
lines changed

drivers/tty/serial/fsl_lpuart.c

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,7 +1276,6 @@ static void rx_dma_timer_init(struct lpuart_port *sport)
12761276
static int lpuart_startup(struct uart_port *port)
12771277
{
12781278
struct lpuart_port *sport = container_of(port, struct lpuart_port, port);
1279-
int ret;
12801279
unsigned long flags;
12811280
unsigned char temp;
12821281

@@ -1291,11 +1290,6 @@ static int lpuart_startup(struct uart_port *port)
12911290
sport->rxfifo_size = 0x1 << (((temp >> UARTPFIFO_RXSIZE_OFF) &
12921291
UARTPFIFO_FIFOSIZE_MASK) + 1);
12931292

1294-
ret = devm_request_irq(port->dev, port->irq, lpuart_int, 0,
1295-
DRIVER_NAME, sport);
1296-
if (ret)
1297-
return ret;
1298-
12991293
spin_lock_irqsave(&sport->port.lock, flags);
13001294

13011295
lpuart_setup_watermark(sport);
@@ -1333,7 +1327,6 @@ static int lpuart_startup(struct uart_port *port)
13331327
static int lpuart32_startup(struct uart_port *port)
13341328
{
13351329
struct lpuart_port *sport = container_of(port, struct lpuart_port, port);
1336-
int ret;
13371330
unsigned long flags;
13381331
unsigned long temp;
13391332

@@ -1346,11 +1339,6 @@ static int lpuart32_startup(struct uart_port *port)
13461339
sport->rxfifo_size = 0x1 << (((temp >> UARTFIFO_RXSIZE_OFF) &
13471340
UARTFIFO_FIFOSIZE_MASK) - 1);
13481341

1349-
ret = devm_request_irq(port->dev, port->irq, lpuart32_int, 0,
1350-
DRIVER_NAME, sport);
1351-
if (ret)
1352-
return ret;
1353-
13541342
spin_lock_irqsave(&sport->port.lock, flags);
13551343

13561344
lpuart32_setup_watermark(sport);
@@ -1380,8 +1368,6 @@ static void lpuart_shutdown(struct uart_port *port)
13801368

13811369
spin_unlock_irqrestore(&port->lock, flags);
13821370

1383-
devm_free_irq(port->dev, port->irq, sport);
1384-
13851371
if (sport->lpuart_dma_rx_use) {
13861372
del_timer_sync(&sport->lpuart_timer);
13871373
lpuart_dma_rx_free(&sport->port);
@@ -1400,7 +1386,6 @@ static void lpuart_shutdown(struct uart_port *port)
14001386

14011387
static void lpuart32_shutdown(struct uart_port *port)
14021388
{
1403-
struct lpuart_port *sport = container_of(port, struct lpuart_port, port);
14041389
unsigned long temp;
14051390
unsigned long flags;
14061391

@@ -1413,8 +1398,6 @@ static void lpuart32_shutdown(struct uart_port *port)
14131398
lpuart32_write(port, temp, UARTCTRL);
14141399

14151400
spin_unlock_irqrestore(&port->lock, flags);
1416-
1417-
devm_free_irq(port->dev, port->irq, sport);
14181401
}
14191402

14201403
static void
@@ -2212,16 +2195,22 @@ static int lpuart_probe(struct platform_device *pdev)
22122195

22132196
platform_set_drvdata(pdev, &sport->port);
22142197

2215-
if (lpuart_is_32(sport))
2198+
if (lpuart_is_32(sport)) {
22162199
lpuart_reg.cons = LPUART32_CONSOLE;
2217-
else
2200+
ret = devm_request_irq(&pdev->dev, sport->port.irq, lpuart32_int, 0,
2201+
DRIVER_NAME, sport);
2202+
} else {
22182203
lpuart_reg.cons = LPUART_CONSOLE;
2204+
ret = devm_request_irq(&pdev->dev, sport->port.irq, lpuart_int, 0,
2205+
DRIVER_NAME, sport);
2206+
}
2207+
2208+
if (ret)
2209+
goto failed_irq_request;
22192210

22202211
ret = uart_add_one_port(&lpuart_reg, &sport->port);
2221-
if (ret) {
2222-
clk_disable_unprepare(sport->clk);
2223-
return ret;
2224-
}
2212+
if (ret)
2213+
goto failed_attach_port;
22252214

22262215
sport->dma_tx_chan = dma_request_slave_channel(sport->port.dev, "tx");
22272216
if (!sport->dma_tx_chan)
@@ -2240,6 +2229,11 @@ static int lpuart_probe(struct platform_device *pdev)
22402229
}
22412230

22422231
return 0;
2232+
2233+
failed_attach_port:
2234+
failed_irq_request:
2235+
clk_disable_unprepare(sport->clk);
2236+
return ret;
22432237
}
22442238

22452239
static int lpuart_remove(struct platform_device *pdev)

0 commit comments

Comments
 (0)