From: Damien Le Moal <damien.lemoal@opensource.wdc.com>
To: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: linux-kernel@vger.kernel.org, linux-ide@vger.kernel.org
Subject: Re: [PATCH] ata: sata_dwc_460ex: Check !irq instead of irq == NO_IRQ
Date: Fri, 11 Nov 2022 17:18:18 +0900 [thread overview]
Message-ID: <5b301bb6-3d50-b6f3-e541-7b6754ceeb7b@opensource.wdc.com> (raw)
In-Reply-To: <a99c89d7b39b63663739f064cd60514938b77833.1668106138.git.christophe.leroy@csgroup.eu>
On 11/11/22 03:50, Christophe Leroy wrote:
> NO_IRQ is a relic from the old days. It is not used anymore in core
> functions. By the way, function irq_of_parse_and_map() returns value 0
> on error.
>
> In some drivers, NO_IRQ is erroneously used to check the return of
> irq_of_parse_and_map().
>
> It is not a real bug today because the only architectures using the
> drivers being fixed by this patch define NO_IRQ as 0, but there are
> architectures which define NO_IRQ as -1. If one day those
> architectures start using the non fixed drivers, there will be a
> problem.
>
> Long time ago Linus advocated for not using NO_IRQ, see
> https://lkml.org/lkml/2005/11/21/221 . He re-iterated the same view
> recently in https://lkml.org/lkml/2022/10/12/622
>
> So test !irq instead of tesing irq == NO_IRQ.
>
> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
> ---
> drivers/ata/sata_dwc_460ex.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/ata/sata_dwc_460ex.c b/drivers/ata/sata_dwc_460ex.c
> index e3263e961045..5fb80ccde65b 100644
> --- a/drivers/ata/sata_dwc_460ex.c
> +++ b/drivers/ata/sata_dwc_460ex.c
> @@ -242,7 +242,7 @@ static int sata_dwc_dma_init_old(struct platform_device *pdev,
>
> /* Get SATA DMA interrupt number */
> hsdev->dma->irq = irq_of_parse_and_map(np, 1);
> - if (hsdev->dma->irq == NO_IRQ) {
> + if (!hsdev->dma->irq) {
> dev_err(dev, "no SATA DMA irq\n");
> return -ENODEV;
> }
> @@ -1180,7 +1180,7 @@ static int sata_dwc_probe(struct platform_device *ofdev)
>
> /* Get SATA interrupt number */
> irq = irq_of_parse_and_map(np, 0);
> - if (irq == NO_IRQ) {
> + if (!irq) {
> dev_err(dev, "no SATA DMA irq\n");
> return -ENODEV;
> }
You can also remove the:
#ifndef NO_IRQ
#define NO_IRQ 0
#endif
at the top of the file.
--
Damien Le Moal
Western Digital Research
prev parent reply other threads:[~2022-11-11 8:18 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-10 18:50 Christophe Leroy
2022-11-11 8:18 ` Damien Le Moal [this message]
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=5b301bb6-3d50-b6f3-e541-7b6754ceeb7b@opensource.wdc.com \
--to=damien.lemoal@opensource.wdc.com \
--cc=christophe.leroy@csgroup.eu \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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®