All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: arvindY <arvind.yadav.cs@gmail.com>
Cc: alsa-devel@alsa-project.org, kernel-janitors@vger.kernel.org,
	Liam Girdwood <lgirdwood@gmail.com>,
	Takashi Iwai <tiwai@suse.com>, Mark Brown <broonie@kernel.org>,
	Alexandre Belloni <alexandre.belloni@free-electrons.com>
Subject: Re: [alsa-devel] [PATCH 1/2] ASoC: nuc900: Fix platform_get_irq() error checking some more
Date: Mon, 11 Dec 2017 08:40:53 +0000	[thread overview]
Message-ID: <20171211084053.p5ke733i3kzzk5mz@mwanda> (raw)
In-Reply-To: <5A2C9E9A.7020501@gmail.com>

On Sun, Dec 10, 2017 at 08:10:26AM +0530, arvindY wrote:
> 
> 
> On Sunday 10 December 2017 07:22 AM, Dan Carpenter wrote:
> > On Sat, Dec 09, 2017 at 06:27:32PM +0100, Alexandre Belloni wrote:
> > > > > diff --git a/sound/soc/nuc900/nuc900-ac97.c b/sound/soc/nuc900/nuc900-ac97.c
> > > > > index 5e4fbd2d3479..71fce7c85c93 100644
> > > > > --- a/sound/soc/nuc900/nuc900-ac97.c
> > > > > +++ b/sound/soc/nuc900/nuc900-ac97.c
> > > > > @@ -345,11 +345,10 @@ static int nuc900_ac97_drvprobe(struct platform_device *pdev)
> > > > >    		goto out;
> > > > >    	}
> > > > > -	nuc900_audio->irq_num = platform_get_irq(pdev, 0);
> > > > > -	if (nuc900_audio->irq_num <= 0) {
> > > > > -		ret = nuc900_audio->irq_num < 0 ? nuc900_audio->irq_num : -EBUSY;
> > > > > +	ret = platform_get_irq(pdev, 0);
> > > > > +	if (ret < 0)
> > > The <= 0 was ok, see:
> > > https://lkml.org/lkml/2017/11/18/41
> > > 
> > Yeah, but is it ever going to return 0?  That seems like a design error
> > and also really crap commenting if so
> yes, It can return 0 on sprac platform and If you see the return of
> platform_get_irq() 'return r ? r->start : -ENXIO;'. It should be
> 'return r && r->start? r->start : -ENXIO;'. We can not add checks here,
> Because There's a bunch of platforms in the kernel they still use IRQ0 as
> valid.
> I have separate mails where few maintainer ask me to add check for 0 and few
> not.
> Adding check for 0 will never harm.

What you're saying doesn't make sense.

You *can't* treat 0 as an error on Sparc because that's a valid IRQ.  In
fact, it seems like if you want to write portable code you should never
treated zero as an error.

It doesn't make sense that someone would register an IRQ resource with
an invalid IRQ number.  In other words, r->start is never going to be
zero on a platform where that's invalid.

So I'm pretty sure "if (ret < 0) " is the correct way to write code and
"if (ret <= 0) " is incorrect but generally harmless except perhaps in
limited situations on SPARC or other similar arches.

regards,
dan carpenter


WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: arvindY <arvind.yadav.cs@gmail.com>
Cc: alsa-devel@alsa-project.org, kernel-janitors@vger.kernel.org,
	Liam Girdwood <lgirdwood@gmail.com>,
	Takashi Iwai <tiwai@suse.com>, Mark Brown <broonie@kernel.org>,
	Alexandre Belloni <alexandre.belloni@free-electrons.com>
Subject: Re: [PATCH 1/2] ASoC: nuc900: Fix platform_get_irq() error checking some more
Date: Mon, 11 Dec 2017 11:40:53 +0300	[thread overview]
Message-ID: <20171211084053.p5ke733i3kzzk5mz@mwanda> (raw)
In-Reply-To: <5A2C9E9A.7020501@gmail.com>

On Sun, Dec 10, 2017 at 08:10:26AM +0530, arvindY wrote:
> 
> 
> On Sunday 10 December 2017 07:22 AM, Dan Carpenter wrote:
> > On Sat, Dec 09, 2017 at 06:27:32PM +0100, Alexandre Belloni wrote:
> > > > > diff --git a/sound/soc/nuc900/nuc900-ac97.c b/sound/soc/nuc900/nuc900-ac97.c
> > > > > index 5e4fbd2d3479..71fce7c85c93 100644
> > > > > --- a/sound/soc/nuc900/nuc900-ac97.c
> > > > > +++ b/sound/soc/nuc900/nuc900-ac97.c
> > > > > @@ -345,11 +345,10 @@ static int nuc900_ac97_drvprobe(struct platform_device *pdev)
> > > > >    		goto out;
> > > > >    	}
> > > > > -	nuc900_audio->irq_num = platform_get_irq(pdev, 0);
> > > > > -	if (nuc900_audio->irq_num <= 0) {
> > > > > -		ret = nuc900_audio->irq_num < 0 ? nuc900_audio->irq_num : -EBUSY;
> > > > > +	ret = platform_get_irq(pdev, 0);
> > > > > +	if (ret < 0)
> > > The <= 0 was ok, see:
> > > https://lkml.org/lkml/2017/11/18/41
> > > 
> > Yeah, but is it ever going to return 0?  That seems like a design error
> > and also really crap commenting if so
> yes, It can return 0 on sprac platform and If you see the return of
> platform_get_irq() 'return r ? r->start : -ENXIO;'. It should be
> 'return r && r->start? r->start : -ENXIO;'. We can not add checks here,
> Because There's a bunch of platforms in the kernel they still use IRQ0 as
> valid.
> I have separate mails where few maintainer ask me to add check for 0 and few
> not.
> Adding check for 0 will never harm.

What you're saying doesn't make sense.

You *can't* treat 0 as an error on Sparc because that's a valid IRQ.  In
fact, it seems like if you want to write portable code you should never
treated zero as an error.

It doesn't make sense that someone would register an IRQ resource with
an invalid IRQ number.  In other words, r->start is never going to be
zero on a platform where that's invalid.

So I'm pretty sure "if (ret < 0) " is the correct way to write code and
"if (ret <= 0) " is incorrect but generally harmless except perhaps in
limited situations on SPARC or other similar arches.

regards,
dan carpenter

  reply	other threads:[~2017-12-11  8:40 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-09 11:52 [PATCH 1/2] ASoC: nuc900: Fix platform_get_irq() error checking some more Dan Carpenter
2017-12-09 11:52 ` Dan Carpenter
2017-12-09 11:52 ` [PATCH 2/2 resend] ASoC: nuc900: Fix a loop timeout test Dan Carpenter
2017-12-09 11:52   ` Dan Carpenter
2017-12-09 13:33 ` [PATCH 1/2] ASoC: nuc900: Fix platform_get_irq() error checking some more arvindY
2017-12-09 13:45   ` arvindY
2017-12-09 17:27   ` [alsa-devel] " Alexandre Belloni
2017-12-09 17:27     ` Alexandre Belloni
2017-12-09 18:37     ` arvindY
2017-12-09 18:49       ` arvindY
2017-12-10  1:52     ` Dan Carpenter
2017-12-10  1:52       ` Dan Carpenter
2017-12-10  2:40       ` [alsa-devel] " arvindY
2017-12-10  2:52         ` arvindY
2017-12-11  8:40         ` Dan Carpenter [this message]
2017-12-11  8:40           ` Dan Carpenter
2017-12-11  9:07           ` [alsa-devel] " Arvind Yadav
2017-12-11  9:19             ` Arvind Yadav
2017-12-11 10:27             ` Dan Carpenter
2017-12-11 10:27               ` Dan Carpenter
2017-12-11 11:49               ` [alsa-devel] " Alexandre Belloni
2017-12-11 11:49                 ` Alexandre Belloni
2017-12-11 12:01                 ` Dan Carpenter
2017-12-11 12:01                   ` Dan Carpenter
2017-12-11 16:41                   ` [alsa-devel] " Alexandre Belloni
2017-12-11 16:41                     ` Alexandre Belloni
2017-12-11 12:02                 ` Mark Brown
2017-12-11 12:02                   ` Mark Brown
2017-12-11 12:14 ` Applied "ASoC: nuc900: Fix platform_get_irq() error checking some more" to the asoc tree Mark Brown
2017-12-11 12:14   ` Mark Brown

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=20171211084053.p5ke733i3kzzk5mz@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=alexandre.belloni@free-electrons.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=arvind.yadav.cs@gmail.com \
    --cc=broonie@kernel.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=tiwai@suse.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 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.