linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tty: serial: imx: Add return value check for platform_get_irq()
@ 2020-05-11  7:09 Anson Huang
  2020-05-11  7:27 ` Uwe Kleine-König
  0 siblings, 1 reply; 3+ messages in thread
From: Anson Huang @ 2020-05-11  7:09 UTC (permalink / raw)
  To: gregkh, jslaby, shawnguo, s.hauer, kernel, festevam,
	linux-serial, linux-arm-kernel, linux-kernel
  Cc: Linux-imx

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

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
---
 drivers/tty/serial/imx.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index f4d6810..f4023d9 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -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);
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] tty: serial: imx: Add return value check for platform_get_irq()
  2020-05-11  7:09 [PATCH] tty: serial: imx: Add return value check for platform_get_irq() Anson Huang
@ 2020-05-11  7:27 ` Uwe Kleine-König
  2020-05-11  7:34   ` Anson Huang
  0 siblings, 1 reply; 3+ messages in thread
From: Uwe Kleine-König @ 2020-05-11  7:27 UTC (permalink / raw)
  To: Anson Huang
  Cc: gregkh, jslaby, shawnguo, s.hauer, kernel, festevam,
	linux-serial, linux-arm-kernel, linux-kernel, Linux-imx

Hello Anson,

On Mon, May 11, 2020 at 03:09:56PM +0800, Anson Huang wrote:
> RX irq is required, so add return value check for platform_get_irq().
> 
> Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
> ---
>  drivers/tty/serial/imx.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
> index f4d6810..f4023d9 100644
> --- a/drivers/tty/serial/imx.c
> +++ b/drivers/tty/serial/imx.c
> @@ -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

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH] tty: serial: imx: Add return value check for platform_get_irq()
  2020-05-11  7:27 ` Uwe Kleine-König
@ 2020-05-11  7:34   ` Anson Huang
  0 siblings, 0 replies; 3+ messages in thread
From: Anson Huang @ 2020-05-11  7:34 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: gregkh, jslaby, shawnguo, s.hauer, kernel, festevam,
	linux-serial, linux-arm-kernel, linux-kernel, dl-linux-imx

Hi, Uwe


> Subject: Re: [PATCH] tty: serial: imx: Add return value check for
> platform_get_irq()
> 
> Hello Anson,
> 
> On Mon, May 11, 2020 at 03:09:56PM +0800, Anson Huang wrote:
> > RX irq is required, so add return value check for platform_get_irq().
> >
> > Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
> > ---
> >  drivers/tty/serial/imx.c | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index
> > f4d6810..f4023d9 100644
> > --- a/drivers/tty/serial/imx.c
> > +++ b/drivers/tty/serial/imx.c
> > @@ -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.

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-05-11  7:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-11  7:09 [PATCH] tty: serial: imx: Add return value check for platform_get_irq() Anson Huang
2020-05-11  7:27 ` Uwe Kleine-König
2020-05-11  7:34   ` Anson Huang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).