Skip to contentSkip to conversation

tty: serial: imx: Add return value check for platform_get_irq()

PATCH In review Anson Huang 2 participants 3 messages May 11, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tty: serial: imx: Add return value check for platform_get_irq()

RX irq is required, so add return value check for platform_get_irq().

---
 drivers/tty/serial/imx.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/tty/serial/imx.c +2 -0
index f4d6810..f4023d9 100644
@@ -2252,6 +2252,8 @@ static int imx_uart_probe(struct platform_device *pdev)
 		return PTR_ERR(base);
 
 	rxirq = platform_get_irq(pdev, 0);
+	if (rxirq < 0)
+		return rxirq;
 	txirq = platform_get_irq_optional(pdev, 1);
 	rtsirq = platform_get_irq_optional(pdev, 2);
 
Signature · 1 line
2.7.4
#1 lore raw

Hello Anson,

Quoted 12 lines · Anson Huang

RX irq is required, so add return value check for platform_get_irq().

---
 drivers/tty/serial/imx.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/tty/serial/imx.c +0 -0
index f4d6810..f4023d9 100644

drivers/tty/serial/imx.c static int imx_uart_probe(struct platform_device *pdev) · line 2258

Quoted 7 lines
drivers/tty/serial/imx.c +2 -0
@@ -2252,6 +2252,8 @@ static int imx_uart_probe(struct platform_device *pdev)
 		return PTR_ERR(base);
 
 	rxirq = platform_get_irq(pdev, 0);
+	if (rxirq < 0)
+		return rxirq;
 	txirq = platform_get_irq_optional(pdev, 1);
 	rtsirq = platform_get_irq_optional(pdev, 2);

I'm not sure we need such a check as devm_request_irq fails if the return value of platform_get_irq() is bogus.

But if we decide this construct is good enough, the error reporting needs some love as currently it emits two error messages which is confusing.

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |
#2 lore raw

Hi, Uwe

Quoted 30 lines

Subject: Re: [PATCH] tty: serial: imx: Add return value check for platform_get_irq()

Hello Anson,

drivers/tty/serial/imx.c static int imx_uart_probe(struct platform_device

Quoted 12 lines · Anson Huang

RX irq is required, so add return value check for platform_get_irq().

---
 drivers/tty/serial/imx.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/tty/serial/imx.c index renamed from drivers/tty/serial/imx.c +0 -0

f4d6810..f4023d9 100644

drivers/tty/serial/imx.c +0 -0
@@ -2252,6 +2252,8 @@ static int imx_uart_probe(struct platform_device

*pdev)

drivers/tty/serial/imx.c static int imx_uart_probe(struct platform_device *pdev) · line 2258

Quoted 7 lines
drivers/tty/serial/imx.c +2 -0
 		return PTR_ERR(base);
 
 	rxirq = platform_get_irq(pdev, 0);
+	if (rxirq < 0)
+		return rxirq;
 	txirq = platform_get_irq_optional(pdev, 1);
 	rtsirq = platform_get_irq_optional(pdev, 2);

I'm not sure we need such a check as devm_request_irq fails if the return value of platform_get_irq() is bogus.

Quoted 2 lines

But if we decide this construct is good enough, the error reporting needs some love as currently it emits two error messages which is confusing.

From the driver, the RX IRQ is always required, if it failed in platform_get_irq(), then the rest of the code is NOT necessary to be executed, and also I am NOT sure if platform_get_irq() failed, the devm_request_irq will always failed?

Not very understand about your last question, the platform_get_irq() already has error message printed out, so no additional error message is needed in the check. If looking through all other drivers, most of the platform_get_irq() are having the return value check, if it failed in platform_get_irq(), driver can just return error from .probe().

Anson