[PATCH v4] serial: mps2-uart: Check for error irq
Jiasheng Jiang
jiasheng at iscas.ac.cn
Thu Dec 23 06:40:37 PST 2021
For the possible failure of the platform_get_irq(), the returned irq
could be error number and will finally cause the failure of the
request_irq().
Consider that platform_get_irq() can now in certain cases
return -EPROBE_DEFER, and the consequences of letting request_irq()
effectively convert that into -EINVAL, even at probe time rather than
later on.
So it might be better to check just now.
Fixes: 041f031def33 ("serial: mps2-uart: add MPS2 UART driver")
Signed-off-by: Jiasheng Jiang <jiasheng at iscas.ac.cn>
---
Changelog:
v3 -> v4
*Change 1. Using error variable to check.
*Change 2. Add new commit message.
*Change 3. Refine the commit message to be more reasonable.
---
drivers/tty/serial/mps2-uart.c | 26 ++++++++++++++++++++++----
1 file changed, 22 insertions(+), 4 deletions(-)
diff --git a/drivers/tty/serial/mps2-uart.c b/drivers/tty/serial/mps2-uart.c
index 587b42f754cb..24a52300d8d9 100644
--- a/drivers/tty/serial/mps2-uart.c
+++ b/drivers/tty/serial/mps2-uart.c
@@ -584,11 +584,29 @@ static int mps2_init_port(struct platform_device *pdev,
if (mps_port->flags & UART_PORT_COMBINED_IRQ) {
- mps_port->port.irq = platform_get_irq(pdev, 0);
+ ret = platform_get_irq(pdev, 0);
+ if (ret < 0)
+ return ret;
+
+ mps_port->port.irq = ret;
} else {
- mps_port->rx_irq = platform_get_irq(pdev, 0);
- mps_port->tx_irq = platform_get_irq(pdev, 1);
- mps_port->port.irq = platform_get_irq(pdev, 2);
+ ret = platform_get_irq(pdev, 0);
+ if (ret < 0)
+ return ret;
+
+ mps_port->rx_irq = ret;
+
+ ret = platform_get_irq(pdev, 1);
+ if (ret < 0)
+ return ret;
+
+ mps_port->tx_irq = ret;
+
+ ret = platform_get_irq(pdev, 2);
+ if (ret < 0)
+ return ret;
+
+ mps_port->port.irq = ret;
}
return ret;
--
2.25.1
More information about the linux-arm-kernel
mailing list