linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] serial: mps2-uart: Check for error irq
@ 2021-12-22  3:36 Jiasheng Jiang
  2021-12-22 10:23 ` Vladimir Murzin
  0 siblings, 1 reply; 2+ messages in thread
From: Jiasheng Jiang @ 2021-12-22  3:36 UTC (permalink / raw)
  To: gregkh, jirislaby, liviu.dudau, sudeep.holla, lorenzo.pieralisi
  Cc: linux-serial, linux-arm-kernel, linux-kernel, Jiasheng Jiang

I find that platform_get_irq() will not always succeed.
It will return error irq in case there is no suitable irq.
Therefore, it might be better to check it if order to avoid the use of
error irq.

Fixes: 041f031def33 ("serial: mps2-uart: add MPS2 UART driver")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
---
 drivers/tty/serial/mps2-uart.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/tty/serial/mps2-uart.c b/drivers/tty/serial/mps2-uart.c
index 587b42f754cb..117d9896051f 100644
--- a/drivers/tty/serial/mps2-uart.c
+++ b/drivers/tty/serial/mps2-uart.c
@@ -585,10 +585,20 @@ 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);
+		if (mps_port->port.irq < 0)
+			return mps_port->port.irq;
 	} else {
 		mps_port->rx_irq = platform_get_irq(pdev, 0);
+		if (mps_port->rx_irq < 0)
+			return mps_port->rx_irq;
+
 		mps_port->tx_irq = platform_get_irq(pdev, 1);
+		if (mps_port->tx_irq < 0)
+			return mps_port->tx_irq;
+
 		mps_port->port.irq = platform_get_irq(pdev, 2);
+		if (mps_port->port.irq < 0)
+			return mps_port->port.irq;
 	}
 
 	return ret;
-- 
2.25.1


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

* Re: [PATCH] serial: mps2-uart: Check for error irq
  2021-12-22  3:36 [PATCH] serial: mps2-uart: Check for error irq Jiasheng Jiang
@ 2021-12-22 10:23 ` Vladimir Murzin
  0 siblings, 0 replies; 2+ messages in thread
From: Vladimir Murzin @ 2021-12-22 10:23 UTC (permalink / raw)
  To: Jiasheng Jiang, gregkh, jirislaby, liviu.dudau, sudeep.holla,
	lorenzo.pieralisi
  Cc: linux-serial, linux-arm-kernel, linux-kernel

On 12/22/21 3:36 AM, Jiasheng Jiang wrote:
> I find that platform_get_irq() will not always succeed.
> It will return error irq in case there is no suitable irq.
> Therefore, it might be better to check it if order to avoid the use of
> error irq.
> 
> Fixes: 041f031def33 ("serial: mps2-uart: add MPS2 UART driver")
> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
> ---
>  drivers/tty/serial/mps2-uart.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/tty/serial/mps2-uart.c b/drivers/tty/serial/mps2-uart.c
> index 587b42f754cb..117d9896051f 100644
> --- a/drivers/tty/serial/mps2-uart.c
> +++ b/drivers/tty/serial/mps2-uart.c
> @@ -585,10 +585,20 @@ 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);
> +		if (mps_port->port.irq < 0)
> +			return mps_port->port.irq;
>  	} else {
>  		mps_port->rx_irq = platform_get_irq(pdev, 0);
> +		if (mps_port->rx_irq < 0)
> +			return mps_port->rx_irq;
> +
>  		mps_port->tx_irq = platform_get_irq(pdev, 1);
> +		if (mps_port->tx_irq < 0)
> +			return mps_port->tx_irq;
> +
>  		mps_port->port.irq = platform_get_irq(pdev, 2);
> +		if (mps_port->port.irq < 0)
> +			return mps_port->port.irq;
>  	}
>  
>  	return ret;
> 

Acked-by: Vladimir Murzin <vladimir.murzin@arm.com>

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

end of thread, other threads:[~2021-12-22 10:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-22  3:36 [PATCH] serial: mps2-uart: Check for error irq Jiasheng Jiang
2021-12-22 10:23 ` Vladimir Murzin

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).