mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Robin Murphy <robin.murphy@arm.com>
To: Jiasheng Jiang <jiasheng@iscas.ac.cn>,
	andy.shevchenko@gmail.com, gregkh@linuxfoundation.org,
	jirislaby@kernel.org, liviu.dudau@arm.com, sudeep.holla@arm.com,
	lorenzo.pieralisi@arm.com
Cc: linux-serial@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] serial: mps2-uart: Check for error irq
Date: Thu, 23 Dec 2021 12:54:06 +0000	[thread overview]
Message-ID: <bd63bad8-df67-4d98-8dd0-26af33ae961b@arm.com> (raw)
In-Reply-To: <20211223121418.1330239-1-jiasheng@iscas.ac.cn>

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;

  reply	other threads:[~2021-12-23 12:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-23 12:14 Jiasheng Jiang
2021-12-23 12:54 ` Robin Murphy [this message]
2021-12-23 13:27 Jiasheng Jiang
2021-12-23 14:26 ` Robin Murphy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bd63bad8-df67-4d98-8dd0-26af33ae961b@arm.com \
    --to=robin.murphy@arm.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jiasheng@iscas.ac.cn \
    --cc=jirislaby@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=liviu.dudau@arm.com \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=sudeep.holla@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®