All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: Dan Carpenter <dan.carpenter@oracle.com>,
	Wim Van Sebroeck <wim@linux-watchdog.org>,
	Linus Walleij <linus.walleij@linaro.org>,
	linux-watchdog@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] watchdog: ftwdt010_wdt: fix test for platform_get_irq() failure
Date: Thu, 11 Aug 2022 14:49:01 -0700	[thread overview]
Message-ID: <20220811214901.GA4089417@roeck-us.net> (raw)
In-Reply-To: <3f1f9300-1d5e-22f8-f544-475a9840d14c@wanadoo.fr>

On Thu, Aug 11, 2022 at 10:52:13PM +0200, Christophe JAILLET wrote:
> Le 11/08/2022 à 12:56, Dan Carpenter a écrit :
> > This code assumes that platform_get_irq() function returns zero on
> > failure.  In fact, platform_get_irq() never returns zero.  It returns
> > negative error codes or positive non-zero values on success.
> > 
> > Fixes: eca10ae6000d ("watchdog: add driver for Cortina Gemini watchdog")
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > ---
> >   drivers/watchdog/ftwdt010_wdt.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/watchdog/ftwdt010_wdt.c b/drivers/watchdog/ftwdt010_wdt.c
> > index 21dcc7765688..02112fc264bd 100644
> > --- a/drivers/watchdog/ftwdt010_wdt.c
> > +++ b/drivers/watchdog/ftwdt010_wdt.c
> > @@ -156,7 +156,7 @@ static int ftwdt010_wdt_probe(struct platform_device *pdev)
> >   	}
> >   	irq = platform_get_irq(pdev, 0);
> > -	if (irq) {
> > +	if (irq > 0) {
> >   		ret = devm_request_irq(dev, irq, ftwdt010_wdt_interrupt, 0,
> >   				       "watchdog bark", gwdt);
> >   		if (ret)
> 
> Hi,
> can't platform_get_irq() return 0?
> All the paths in platform_get_irq() look like 0 is a valid value.
> 
> The other patches you just sent are "< 0 ==> error", so ">= 0 ==> valid"
> 
> Any reason here for >0?

API documentation says:

* Return: non-zero IRQ number on success, negative error number on failure.

Also, 0 is not a valid interrupt number.

Guenter

  reply	other threads:[~2022-08-11 21:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-11 10:56 [PATCH] watchdog: ftwdt010_wdt: fix test for platform_get_irq() failure Dan Carpenter
2022-08-11 14:56 ` Guenter Roeck
2022-08-11 20:52 ` Christophe JAILLET
2022-08-11 21:49   ` Guenter Roeck [this message]
2022-08-12  6:07   ` Dan Carpenter
2022-08-12  7:22     ` Christophe JAILLET

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=20220811214901.GA4089417@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=dan.carpenter@oracle.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=wim@linux-watchdog.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.