linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Slaby <jirislaby@kernel.org>
To: Hugo Villeneuve <hugo@hugovil.com>, Yi Yang <yiyang13@huawei.com>
Cc: gregkh@linuxfoundation.org, srinivas.kandagatla@st.com,
	linux-arm-kernel@lists.infradead.org,
	linux-serial@vger.kernel.org
Subject: Re: [PATCH] serial: st-asc: Check return value of platform_get_irq() in asc_init_port()
Date: Thu, 19 Oct 2023 07:02:32 +0200	[thread overview]
Message-ID: <9316aaef-6079-4151-89df-bdd4ff422707@kernel.org> (raw)
In-Reply-To: <20231018142818.16eea64d71410c6717da41ba@hugovil.com>

On 18. 10. 23, 20:28, Hugo Villeneuve wrote:
> On Wed, 18 Oct 2023 09:12:40 +0000
> Yi Yang <yiyang13@huawei.com> wrote:
> 
>> The platform_get_irq() might be failed and return a negative result, there
>> should be return an error code when platform_get_irq() failed.
>> Fix it by add check return value of platform_get_irq().
>>
>> Fixes: c4b058560762 ("serial:st-asc: Add ST ASC driver.")
>> Signed-off-by: Yi Yang <yiyang13@huawei.com>
>> ---
>>   drivers/tty/serial/st-asc.c | 6 +++++-
>>   1 file changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/tty/serial/st-asc.c b/drivers/tty/serial/st-asc.c
>> index a821f5d76a26..8321167502dc 100644
>> --- a/drivers/tty/serial/st-asc.c
>> +++ b/drivers/tty/serial/st-asc.c
>> @@ -683,12 +683,16 @@ static int asc_init_port(struct asc_port *ascport,
>>   	struct resource *res;
>>   	int ret;
>>   
>> +	ret = platform_get_irq(pdev, 0);
> 
> Hi,
> for readability, you could define a new irq variable instead of using
> ret. See reasoning below.
> 
>> +	if (ret < 0)
>> +		return ret;
>> +
>>   	port->iotype	= UPIO_MEM;
>>   	port->flags	= UPF_BOOT_AUTOCONF;
>>   	port->ops	= &asc_uart_ops;
>>   	port->fifosize	= ASC_FIFO_SIZE;
>>   	port->dev	= &pdev->dev;
>> -	port->irq	= platform_get_irq(pdev, 0);
>> +	port->irq	= ret;
> 
> Assigning port->irq to irq instead of ret will make the code more
> understandable.

Yes. And you need not to worry that someone will stick another
ret = something();
after platform_get_irq() above.

thanks,
-- 
js
suse labs


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2023-10-19  5:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-18  9:12 [PATCH] serial: st-asc: Check return value of platform_get_irq() in asc_init_port() Yi Yang
2023-10-18 18:28 ` Hugo Villeneuve
2023-10-19  5:02   ` Jiri Slaby [this message]
2023-10-18 18:35 ` Hugo Villeneuve

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=9316aaef-6079-4151-89df-bdd4ff422707@kernel.org \
    --to=jirislaby@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hugo@hugovil.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=srinivas.kandagatla@st.com \
    --cc=yiyang13@huawei.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;
as well as URLs for NNTP newsgroup(s).