linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: Re: [PATCH v3] serial: mps2-uart: Check for error irq
@ 2021-12-23 13:27 Jiasheng Jiang
  2021-12-23 14:26 ` Robin Murphy
  0 siblings, 1 reply; 4+ messages in thread
From: Jiasheng Jiang @ 2021-12-23 13:27 UTC (permalink / raw)
  To: robin.murphy, andy.shevchenko, gregkh, jirislaby, liviu.dudau,
	sudeep.holla, lorenzo.pieralisi
  Cc: linux-serial, linux-arm-kernel, linux-kernel, Jiasheng Jiang

On 2021-12-23 12:54, Robin Murphy wrote:
>> Because of the possible failure of the platform_get_irq(), it should be
>> better to check it to avoid the use of error irq.
>
> As far as I can see, the only "use" of error values is that they will be 
> passed to request_irq(), which will then return -EINVAL because they are 
> not valid IRQ numbers, and that error will be handled appropriately. I 
> think that's a relatively common pattern, so your commit message should 
> really describe why you think it's a problem and why this addition is a 
> meaningful improvement.

Thanks for your reminder, and I correct my commit message as follow.
If that's ok, I will correct my other patches like this.

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().
So it might be better to check just now in order to avoid the waste of
later processes.

Sincerely thanks,
Jiasheng


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

* Re: [PATCH v3] serial: mps2-uart: Check for error irq
  2021-12-23 13:27 Re: [PATCH v3] serial: mps2-uart: Check for error irq Jiasheng Jiang
@ 2021-12-23 14:26 ` Robin Murphy
  0 siblings, 0 replies; 4+ messages in thread
From: Robin Murphy @ 2021-12-23 14:26 UTC (permalink / raw)
  To: Jiasheng Jiang, andy.shevchenko, gregkh, jirislaby, liviu.dudau,
	sudeep.holla, lorenzo.pieralisi
  Cc: linux-serial, linux-arm-kernel, linux-kernel

On 2021-12-23 13:27, Jiasheng Jiang wrote:
> On 2021-12-23 12:54, Robin Murphy wrote:
>>> Because of the possible failure of the platform_get_irq(), it should be
>>> better to check it to avoid the use of error irq.
>>
>> As far as I can see, the only "use" of error values is that they will be
>> passed to request_irq(), which will then return -EINVAL because they are
>> not valid IRQ numbers, and that error will be handled appropriately. I
>> think that's a relatively common pattern, so your commit message should
>> really describe why you think it's a problem and why this addition is a
>> meaningful improvement.
> 
> Thanks for your reminder, and I correct my commit message as follow.
> If that's ok, I will correct my other patches like this.
> 
> 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().
> So it might be better to check just now in order to avoid the waste of
> later processes.

Even better, 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 ;)

Cheers,
Robin.

> 
> Sincerely thanks,
> Jiasheng
> 

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

* Re: [PATCH v3] serial: mps2-uart: Check for error irq
  2021-12-23 12:14 Jiasheng Jiang
@ 2021-12-23 12:54 ` Robin Murphy
  0 siblings, 0 replies; 4+ messages in thread
From: Robin Murphy @ 2021-12-23 12:54 UTC (permalink / raw)
  To: Jiasheng Jiang, andy.shevchenko, gregkh, jirislaby, liviu.dudau,
	sudeep.holla, lorenzo.pieralisi
  Cc: linux-serial, linux-arm-kernel, linux-kernel

On 2021-12-23 12:14, Jiasheng Jiang wrote:
> Because of the possible failure of the platform_get_irq(), it should be
> better to check it to avoid the use of error irq.

As far as I can see, the only "use" of error values is that they will be 
passed to request_irq(), which will then return -EINVAL because they are 
not valid IRQ numbers, and that error will be handled appropriately. I 
think that's a relatively common pattern, so your commit message should 
really describe why you think it's a problem and why this addition is a 
meaningful improvement.

Robin.

> Fixes: 041f031def33 ("serial: mps2-uart: add MPS2 UART driver")
> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
> ---
> Changelog:
> 
> v2 -> v3
> 
> *Change 1. Using error variable to check.
> *Change 2. Add new commit message.
> ---
>   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;

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

* [PATCH v3] serial: mps2-uart: Check for error irq
@ 2021-12-23 12:14 Jiasheng Jiang
  2021-12-23 12:54 ` Robin Murphy
  0 siblings, 1 reply; 4+ messages in thread
From: Jiasheng Jiang @ 2021-12-23 12:14 UTC (permalink / raw)
  To: andy.shevchenko, gregkh, jirislaby, liviu.dudau, sudeep.holla,
	lorenzo.pieralisi
  Cc: linux-serial, linux-arm-kernel, linux-kernel, Jiasheng Jiang

Because of the possible failure of the platform_get_irq(), it should be
better to check it 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>
---
Changelog:

v2 -> v3

*Change 1. Using error variable to check.
*Change 2. Add new commit message.
---
 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


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

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

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-23 13:27 Re: [PATCH v3] serial: mps2-uart: Check for error irq Jiasheng Jiang
2021-12-23 14:26 ` Robin Murphy
  -- strict thread matches above, loose matches on Subject: below --
2021-12-23 12:14 Jiasheng Jiang
2021-12-23 12:54 ` Robin Murphy

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