All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] ASoC: nuc900: Fix platform_get_irq() error checking some more
@ 2017-12-09 11:52 ` Dan Carpenter
  0 siblings, 0 replies; 30+ messages in thread
From: Dan Carpenter @ 2017-12-09 11:52 UTC (permalink / raw)
  To: Liam Girdwood, Arvind Yadav
  Cc: alsa-devel, Mark Brown, kernel-janitors, Takashi Iwai

The error handling doesn't work here because "nuc900_audio->irq_num" is
unsigned.  Also we should be checking for < 0 and not <= 0 but I believe
that's harmless.  The platform_get_irq() comments don't talk about the
return values...

Fixes: fa8cc38165c2 ("ASoC: nuc900: Fix platform_get_irq's error checking")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

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)
 		goto out;
-	}
+	nuc900_audio->irq_num = ret;
 
 	nuc900_ac97_data = nuc900_audio;
 

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 1/2] ASoC: nuc900: Fix platform_get_irq() error checking some more
@ 2017-12-09 11:52 ` Dan Carpenter
  0 siblings, 0 replies; 30+ messages in thread
From: Dan Carpenter @ 2017-12-09 11:52 UTC (permalink / raw)
  To: Liam Girdwood, Arvind Yadav
  Cc: alsa-devel, Mark Brown, kernel-janitors, Takashi Iwai

The error handling doesn't work here because "nuc900_audio->irq_num" is
unsigned.  Also we should be checking for < 0 and not <= 0 but I believe
that's harmless.  The platform_get_irq() comments don't talk about the
return values...

Fixes: fa8cc38165c2 ("ASoC: nuc900: Fix platform_get_irq's error checking")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

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)
 		goto out;
-	}
+	nuc900_audio->irq_num = ret;
 
 	nuc900_ac97_data = nuc900_audio;
 

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 2/2 resend] ASoC: nuc900: Fix a loop timeout test
  2017-12-09 11:52 ` Dan Carpenter
@ 2017-12-09 11:52   ` Dan Carpenter
  -1 siblings, 0 replies; 30+ messages in thread
From: Dan Carpenter @ 2017-12-09 11:52 UTC (permalink / raw)
  To: Liam Girdwood, Wan ZongShun
  Cc: alsa-devel, kernel-janitors, Takashi Iwai, Mark Brown, Arvind Yadav

We should be finishing the loop with timeout set to zero but because
this is a post-op we finish with timeout = -1.

Fixes: 1082e2703a2d ("ASoC: NUC900/audio: add nuc900 audio driver support")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
I sent this one in July but it was missed somehow.

diff --git a/sound/soc/nuc900/nuc900-ac97.c b/sound/soc/nuc900/nuc900-ac97.c
index 71fce7c85c93..81b09d740ed9 100644
--- a/sound/soc/nuc900/nuc900-ac97.c
+++ b/sound/soc/nuc900/nuc900-ac97.c
@@ -67,7 +67,7 @@ static unsigned short nuc900_ac97_read(struct snd_ac97 *ac97,
 
 	/* polling the AC_R_FINISH */
 	while (!(AUDIO_READ(nuc900_audio->mmio + ACTL_ACCON) & AC_R_FINISH)
-								&& timeout--)
+								&& --timeout)
 		mdelay(1);
 
 	if (!timeout) {
@@ -121,7 +121,7 @@ static void nuc900_ac97_write(struct snd_ac97 *ac97, unsigned short reg,
 
 	/* polling the AC_W_FINISH */
 	while ((AUDIO_READ(nuc900_audio->mmio + ACTL_ACCON) & AC_W_FINISH)
-								&& timeout--)
+								&& --timeout)
 		mdelay(1);
 
 	if (!timeout)

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 2/2 resend] ASoC: nuc900: Fix a loop timeout test
@ 2017-12-09 11:52   ` Dan Carpenter
  0 siblings, 0 replies; 30+ messages in thread
From: Dan Carpenter @ 2017-12-09 11:52 UTC (permalink / raw)
  To: Liam Girdwood, Wan ZongShun
  Cc: alsa-devel, kernel-janitors, Takashi Iwai, Mark Brown, Arvind Yadav

We should be finishing the loop with timeout set to zero but because
this is a post-op we finish with timeout == -1.

Fixes: 1082e2703a2d ("ASoC: NUC900/audio: add nuc900 audio driver support")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
I sent this one in July but it was missed somehow.

diff --git a/sound/soc/nuc900/nuc900-ac97.c b/sound/soc/nuc900/nuc900-ac97.c
index 71fce7c85c93..81b09d740ed9 100644
--- a/sound/soc/nuc900/nuc900-ac97.c
+++ b/sound/soc/nuc900/nuc900-ac97.c
@@ -67,7 +67,7 @@ static unsigned short nuc900_ac97_read(struct snd_ac97 *ac97,
 
 	/* polling the AC_R_FINISH */
 	while (!(AUDIO_READ(nuc900_audio->mmio + ACTL_ACCON) & AC_R_FINISH)
-								&& timeout--)
+								&& --timeout)
 		mdelay(1);
 
 	if (!timeout) {
@@ -121,7 +121,7 @@ static void nuc900_ac97_write(struct snd_ac97 *ac97, unsigned short reg,
 
 	/* polling the AC_W_FINISH */
 	while ((AUDIO_READ(nuc900_audio->mmio + ACTL_ACCON) & AC_W_FINISH)
-								&& timeout--)
+								&& --timeout)
 		mdelay(1);
 
 	if (!timeout)

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* Re: [PATCH 1/2] ASoC: nuc900: Fix platform_get_irq() error checking some more
  2017-12-09 11:52 ` Dan Carpenter
@ 2017-12-09 13:45   ` arvindY
  -1 siblings, 0 replies; 30+ messages in thread
From: arvindY @ 2017-12-09 13:33 UTC (permalink / raw)
  To: Dan Carpenter, Liam Girdwood
  Cc: Mark Brown, Jaroslav Kysela, Takashi Iwai, alsa-devel, kernel-janitors

Hi Dan,

On Saturday 09 December 2017 05:22 PM, Dan Carpenter wrote:
> The error handling doesn't work here because "nuc900_audio->irq_num" is
> unsigned.  Also we should be checking for < 0 and not <= 0 but I believe
> that's harmless.  The platform_get_irq() comments don't talk about the
> return values...
Sorry for this  patch. I will fix it and send you updated patch.
Thanks for point it.
> Fixes: fa8cc38165c2 ("ASoC: nuc900: Fix platform_get_irq's error checking")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> 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)
>   		goto out;
> -	}
> +	nuc900_audio->irq_num = ret;
>   
>   	nuc900_ac97_data = nuc900_audio;
>   
~arvind

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 1/2] ASoC: nuc900: Fix platform_get_irq() error checking some more
@ 2017-12-09 13:45   ` arvindY
  0 siblings, 0 replies; 30+ messages in thread
From: arvindY @ 2017-12-09 13:45 UTC (permalink / raw)
  To: Dan Carpenter, Liam Girdwood
  Cc: Mark Brown, Jaroslav Kysela, Takashi Iwai, alsa-devel, kernel-janitors

Hi Dan,

On Saturday 09 December 2017 05:22 PM, Dan Carpenter wrote:
> The error handling doesn't work here because "nuc900_audio->irq_num" is
> unsigned.  Also we should be checking for < 0 and not <= 0 but I believe
> that's harmless.  The platform_get_irq() comments don't talk about the
> return values...
Sorry for this  patch. I will fix it and send you updated patch.
Thanks for point it.
> Fixes: fa8cc38165c2 ("ASoC: nuc900: Fix platform_get_irq's error checking")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> 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)
>   		goto out;
> -	}
> +	nuc900_audio->irq_num = ret;
>   
>   	nuc900_ac97_data = nuc900_audio;
>   
~arvind

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [alsa-devel] [PATCH 1/2] ASoC: nuc900: Fix platform_get_irq() error checking some more
  2017-12-09 13:45   ` arvindY
@ 2017-12-09 17:27     ` Alexandre Belloni
  -1 siblings, 0 replies; 30+ messages in thread
From: Alexandre Belloni @ 2017-12-09 17:27 UTC (permalink / raw)
  To: arvindY
  Cc: Dan Carpenter, Liam Girdwood, alsa-devel, Mark Brown,
	kernel-janitors, Takashi Iwai

Arvind,

This was v5 and it contains an error that was corrected between v1 and
v2. For whatever reason, you reintroduced it between v4 and v5.

This is wasting a lot of time.

On 09/12/2017 at 19:03:56 +0530, arvindY wrote:
> Hi Dan,
> 
> On Saturday 09 December 2017 05:22 PM, Dan Carpenter wrote:
> > The error handling doesn't work here because "nuc900_audio->irq_num" is
> > unsigned.  Also we should be checking for < 0 and not <= 0 but I believe
> > that's harmless.  The platform_get_irq() comments don't talk about the
> > return values...
> Sorry for this  patch. I will fix it and send you updated patch.
> Thanks for point it.
> > Fixes: fa8cc38165c2 ("ASoC: nuc900: Fix platform_get_irq's error checking")
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > 
> > 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


-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [alsa-devel] [PATCH 1/2] ASoC: nuc900: Fix platform_get_irq() error checking some more
@ 2017-12-09 17:27     ` Alexandre Belloni
  0 siblings, 0 replies; 30+ messages in thread
From: Alexandre Belloni @ 2017-12-09 17:27 UTC (permalink / raw)
  To: arvindY
  Cc: Dan Carpenter, Liam Girdwood, alsa-devel, Mark Brown,
	kernel-janitors, Takashi Iwai

Arvind,

This was v5 and it contains an error that was corrected between v1 and
v2. For whatever reason, you reintroduced it between v4 and v5.

This is wasting a lot of time.

On 09/12/2017 at 19:03:56 +0530, arvindY wrote:
> Hi Dan,
> 
> On Saturday 09 December 2017 05:22 PM, Dan Carpenter wrote:
> > The error handling doesn't work here because "nuc900_audio->irq_num" is
> > unsigned.  Also we should be checking for < 0 and not <= 0 but I believe
> > that's harmless.  The platform_get_irq() comments don't talk about the
> > return values...
> Sorry for this  patch. I will fix it and send you updated patch.
> Thanks for point it.
> > Fixes: fa8cc38165c2 ("ASoC: nuc900: Fix platform_get_irq's error checking")
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > 
> > 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


-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [alsa-devel] [PATCH 1/2] ASoC: nuc900: Fix platform_get_irq() error checking some more
  2017-12-09 17:27     ` Alexandre Belloni
@ 2017-12-09 18:49       ` arvindY
  -1 siblings, 0 replies; 30+ messages in thread
From: arvindY @ 2017-12-09 18:37 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: Dan Carpenter, Liam Girdwood, alsa-devel, Mark Brown,
	kernel-janitors, Takashi Iwai

Hi,

On Saturday 09 December 2017 10:57 PM, Alexandre Belloni wrote:
> Arvind,
>
> This was v5 and it contains an error that was corrected between v1 and
> v2. For whatever reason, you reintroduced it between v4 and v5.
>
> This is wasting a lot of time.
Yes, You are right. That is my mistake.  Next time I will try to avoid
These kind of error.

>
> On 09/12/2017 at 19:03:56 +0530, arvindY wrote:
>> Hi Dan,
>>
>> On Saturday 09 December 2017 05:22 PM, Dan Carpenter wrote:
>>> The error handling doesn't work here because "nuc900_audio->irq_num" is
>>> unsigned.  Also we should be checking for < 0 and not <= 0 but I believe
>>> that's harmless.  The platform_get_irq() comments don't talk about the
>>> return values...
>> Sorry for this  patch. I will fix it and send you updated patch.
>> Thanks for point it.
Thanks for Fix. Please ignore my previous comment.
>>> Fixes: fa8cc38165c2 ("ASoC: nuc900: Fix platform_get_irq's error checking")
>>> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Arvind Yadav <Arvind.yadav.cs@gmail.com>
>>>
>>> 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
>
>
~arvind

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [alsa-devel] [PATCH 1/2] ASoC: nuc900: Fix platform_get_irq() error checking some more
@ 2017-12-09 18:49       ` arvindY
  0 siblings, 0 replies; 30+ messages in thread
From: arvindY @ 2017-12-09 18:49 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: Dan Carpenter, Liam Girdwood, alsa-devel, Mark Brown,
	kernel-janitors, Takashi Iwai

Hi,

On Saturday 09 December 2017 10:57 PM, Alexandre Belloni wrote:
> Arvind,
>
> This was v5 and it contains an error that was corrected between v1 and
> v2. For whatever reason, you reintroduced it between v4 and v5.
>
> This is wasting a lot of time.
Yes, You are right. That is my mistake.  Next time I will try to avoid
These kind of error.

>
> On 09/12/2017 at 19:03:56 +0530, arvindY wrote:
>> Hi Dan,
>>
>> On Saturday 09 December 2017 05:22 PM, Dan Carpenter wrote:
>>> The error handling doesn't work here because "nuc900_audio->irq_num" is
>>> unsigned.  Also we should be checking for < 0 and not <= 0 but I believe
>>> that's harmless.  The platform_get_irq() comments don't talk about the
>>> return values...
>> Sorry for this  patch. I will fix it and send you updated patch.
>> Thanks for point it.
Thanks for Fix. Please ignore my previous comment.
>>> Fixes: fa8cc38165c2 ("ASoC: nuc900: Fix platform_get_irq's error checking")
>>> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Arvind Yadav <Arvind.yadav.cs@gmail.com>
>>>
>>> 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
>
>
~arvind

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [alsa-devel] [PATCH 1/2] ASoC: nuc900: Fix platform_get_irq() error checking some more
  2017-12-09 17:27     ` Alexandre Belloni
@ 2017-12-10  1:52       ` Dan Carpenter
  -1 siblings, 0 replies; 30+ messages in thread
From: Dan Carpenter @ 2017-12-10  1:52 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: alsa-devel, kernel-janitors, Liam Girdwood, Takashi Iwai,
	Mark Brown, arvindY

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.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 1/2] ASoC: nuc900: Fix platform_get_irq() error checking some more
@ 2017-12-10  1:52       ` Dan Carpenter
  0 siblings, 0 replies; 30+ messages in thread
From: Dan Carpenter @ 2017-12-10  1:52 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: alsa-devel, kernel-janitors, Liam Girdwood, Takashi Iwai,
	Mark Brown, arvindY

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.

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [alsa-devel] [PATCH 1/2] ASoC: nuc900: Fix platform_get_irq() error checking some more
  2017-12-10  1:52       ` Dan Carpenter
@ 2017-12-10  2:52         ` arvindY
  -1 siblings, 0 replies; 30+ messages in thread
From: arvindY @ 2017-12-10  2:40 UTC (permalink / raw)
  To: Dan Carpenter, Alexandre Belloni
  Cc: Liam Girdwood, alsa-devel, Mark Brown, kernel-janitors, Takashi Iwai



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.
>
> regards,
> dan carpenter
>
~arvind

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [alsa-devel] [PATCH 1/2] ASoC: nuc900: Fix platform_get_irq() error checking some more
@ 2017-12-10  2:52         ` arvindY
  0 siblings, 0 replies; 30+ messages in thread
From: arvindY @ 2017-12-10  2:52 UTC (permalink / raw)
  To: Dan Carpenter, Alexandre Belloni
  Cc: Liam Girdwood, alsa-devel, Mark Brown, kernel-janitors, Takashi Iwai



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.
>
> regards,
> dan carpenter
>
~arvind

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [alsa-devel] [PATCH 1/2] ASoC: nuc900: Fix platform_get_irq() error checking some more
  2017-12-10  2:52         ` arvindY
@ 2017-12-11  8:40           ` Dan Carpenter
  -1 siblings, 0 replies; 30+ messages in thread
From: Dan Carpenter @ 2017-12-11  8:40 UTC (permalink / raw)
  To: arvindY
  Cc: alsa-devel, kernel-janitors, Liam Girdwood, Takashi Iwai,
	Mark Brown, Alexandre Belloni

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


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 1/2] ASoC: nuc900: Fix platform_get_irq() error checking some more
@ 2017-12-11  8:40           ` Dan Carpenter
  0 siblings, 0 replies; 30+ messages in thread
From: Dan Carpenter @ 2017-12-11  8:40 UTC (permalink / raw)
  To: arvindY
  Cc: alsa-devel, kernel-janitors, Liam Girdwood, Takashi Iwai,
	Mark Brown, Alexandre Belloni

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

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [alsa-devel] [PATCH 1/2] ASoC: nuc900: Fix platform_get_irq() error checking some more
  2017-12-11  8:40           ` Dan Carpenter
@ 2017-12-11  9:19             ` Arvind Yadav
  -1 siblings, 0 replies; 30+ messages in thread
From: Arvind Yadav @ 2017-12-11  9:07 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Alexandre Belloni, Liam Girdwood, alsa-devel, Mark Brown,
	kernel-janitors, Takashi Iwai

Hi Dan,


On Monday 11 December 2017 02:10 PM, Dan Carpenter wrote:
> 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.
I am following a below link. Where they have point out irq 0 is not valid.
https://lwn.net/Articles/470820/
>
> 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
>
~arvind

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [alsa-devel] [PATCH 1/2] ASoC: nuc900: Fix platform_get_irq() error checking some more
@ 2017-12-11  9:19             ` Arvind Yadav
  0 siblings, 0 replies; 30+ messages in thread
From: Arvind Yadav @ 2017-12-11  9:19 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Alexandre Belloni, Liam Girdwood, alsa-devel, Mark Brown,
	kernel-janitors, Takashi Iwai

Hi Dan,


On Monday 11 December 2017 02:10 PM, Dan Carpenter wrote:
> 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.
I am following a below link. Where they have point out irq 0 is not valid.
https://lwn.net/Articles/470820/
>
> 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
>
~arvind

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [alsa-devel] [PATCH 1/2] ASoC: nuc900: Fix platform_get_irq() error checking some more
  2017-12-11  9:19             ` Arvind Yadav
@ 2017-12-11 10:27               ` Dan Carpenter
  -1 siblings, 0 replies; 30+ messages in thread
From: Dan Carpenter @ 2017-12-11 10:27 UTC (permalink / raw)
  To: Arvind Yadav
  Cc: alsa-devel, kernel-janitors, Liam Girdwood, Takashi Iwai,
	Mark Brown, Alexandre Belloni

On Mon, Dec 11, 2017 at 02:37:22PM +0530, Arvind Yadav wrote:
> Hi Dan,
> 
> 
> On Monday 11 December 2017 02:10 PM, Dan Carpenter wrote:
> > 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.
> I am following a below link. Where they have point out irq 0 is not valid.
> https://lwn.net/Articles/470820/

That article is interesting and explains why this stuff is so messed up,
but I think my email is correct.  No one is going to tell the kernel,
"There is an IRQ resource at 0, please store it in r->start.  We can't
use that IRQ, it's only there to make the kernel crash when people call
platform_get_irq()!  #geniusidea."

There are other IRQ functions like irq_of_parse_and_map() which do
return zero on error but platform_get_irq() pretty clearly returns
negative error codes.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 1/2] ASoC: nuc900: Fix platform_get_irq() error checking some more
@ 2017-12-11 10:27               ` Dan Carpenter
  0 siblings, 0 replies; 30+ messages in thread
From: Dan Carpenter @ 2017-12-11 10:27 UTC (permalink / raw)
  To: Arvind Yadav
  Cc: alsa-devel, kernel-janitors, Liam Girdwood, Takashi Iwai,
	Mark Brown, Alexandre Belloni

On Mon, Dec 11, 2017 at 02:37:22PM +0530, Arvind Yadav wrote:
> Hi Dan,
> 
> 
> On Monday 11 December 2017 02:10 PM, Dan Carpenter wrote:
> > 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.
> I am following a below link. Where they have point out irq 0 is not valid.
> https://lwn.net/Articles/470820/

That article is interesting and explains why this stuff is so messed up,
but I think my email is correct.  No one is going to tell the kernel,
"There is an IRQ resource at 0, please store it in r->start.  We can't
use that IRQ, it's only there to make the kernel crash when people call
platform_get_irq()!  #geniusidea."

There are other IRQ functions like irq_of_parse_and_map() which do
return zero on error but platform_get_irq() pretty clearly returns
negative error codes.

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [alsa-devel] [PATCH 1/2] ASoC: nuc900: Fix platform_get_irq() error checking some more
  2017-12-11 10:27               ` Dan Carpenter
@ 2017-12-11 11:49                 ` Alexandre Belloni
  -1 siblings, 0 replies; 30+ messages in thread
From: Alexandre Belloni @ 2017-12-11 11:49 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Arvind Yadav, Liam Girdwood, alsa-devel, Mark Brown,
	kernel-janitors, Takashi Iwai

On 11/12/2017 at 13:27:30 +0300, Dan Carpenter wrote:
> On Mon, Dec 11, 2017 at 02:37:22PM +0530, Arvind Yadav wrote:
> > Hi Dan,
> > 
> > 
> > On Monday 11 December 2017 02:10 PM, Dan Carpenter wrote:
> > > 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.
> > I am following a below link. Where they have point out irq 0 is not valid.
> > https://lwn.net/Articles/470820/
> 
> That article is interesting and explains why this stuff is so messed up,
> but I think my email is correct.  No one is going to tell the kernel,
> "There is an IRQ resource at 0, please store it in r->start.  We can't
> use that IRQ, it's only there to make the kernel crash when people call
> platform_get_irq()!  #geniusidea."
> 
> There are other IRQ functions like irq_of_parse_and_map() which do
> return zero on error but platform_get_irq() pretty clearly returns
> negative error codes.
> 
> regards,
> dan carpenter
> 

Maybe the good thing to do is to actaully leave the nuc900 code alone
instead of trying to change something that never failed and that doesn't
seem to interest anyone anymore (else the platform would have been
converted to DT).

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [alsa-devel] [PATCH 1/2] ASoC: nuc900: Fix platform_get_irq() error checking some more
@ 2017-12-11 11:49                 ` Alexandre Belloni
  0 siblings, 0 replies; 30+ messages in thread
From: Alexandre Belloni @ 2017-12-11 11:49 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Arvind Yadav, Liam Girdwood, alsa-devel, Mark Brown,
	kernel-janitors, Takashi Iwai

On 11/12/2017 at 13:27:30 +0300, Dan Carpenter wrote:
> On Mon, Dec 11, 2017 at 02:37:22PM +0530, Arvind Yadav wrote:
> > Hi Dan,
> > 
> > 
> > On Monday 11 December 2017 02:10 PM, Dan Carpenter wrote:
> > > 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.
> > I am following a below link. Where they have point out irq 0 is not valid.
> > https://lwn.net/Articles/470820/
> 
> That article is interesting and explains why this stuff is so messed up,
> but I think my email is correct.  No one is going to tell the kernel,
> "There is an IRQ resource at 0, please store it in r->start.  We can't
> use that IRQ, it's only there to make the kernel crash when people call
> platform_get_irq()!  #geniusidea."
> 
> There are other IRQ functions like irq_of_parse_and_map() which do
> return zero on error but platform_get_irq() pretty clearly returns
> negative error codes.
> 
> regards,
> dan carpenter
> 

Maybe the good thing to do is to actaully leave the nuc900 code alone
instead of trying to change something that never failed and that doesn't
seem to interest anyone anymore (else the platform would have been
converted to DT).

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [alsa-devel] [PATCH 1/2] ASoC: nuc900: Fix platform_get_irq() error checking some more
  2017-12-11 11:49                 ` Alexandre Belloni
@ 2017-12-11 12:01                   ` Dan Carpenter
  -1 siblings, 0 replies; 30+ messages in thread
From: Dan Carpenter @ 2017-12-11 12:01 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: alsa-devel, kernel-janitors, Liam Girdwood, Takashi Iwai,
	Mark Brown, Arvind Yadav

On Mon, Dec 11, 2017 at 12:49:50PM +0100, Alexandre Belloni wrote:
> Maybe the good thing to do is to actaully leave the nuc900 code alone
> instead of trying to change something that never failed and that doesn't
> seem to interest anyone anymore (else the platform would have been
> converted to DT).
>

I don't know.  The bug is less than a month old and this discussion has
been useful for me as I review any platform_get_irq() changes sent to
staging.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 1/2] ASoC: nuc900: Fix platform_get_irq() error checking some more
@ 2017-12-11 12:01                   ` Dan Carpenter
  0 siblings, 0 replies; 30+ messages in thread
From: Dan Carpenter @ 2017-12-11 12:01 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: alsa-devel, kernel-janitors, Liam Girdwood, Takashi Iwai,
	Mark Brown, Arvind Yadav

On Mon, Dec 11, 2017 at 12:49:50PM +0100, Alexandre Belloni wrote:
> Maybe the good thing to do is to actaully leave the nuc900 code alone
> instead of trying to change something that never failed and that doesn't
> seem to interest anyone anymore (else the platform would have been
> converted to DT).
>

I don't know.  The bug is less than a month old and this discussion has
been useful for me as I review any platform_get_irq() changes sent to
staging.

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [alsa-devel] [PATCH 1/2] ASoC: nuc900: Fix platform_get_irq() error checking some more
  2017-12-11 11:49                 ` Alexandre Belloni
@ 2017-12-11 12:02                   ` Mark Brown
  -1 siblings, 0 replies; 30+ messages in thread
From: Mark Brown @ 2017-12-11 12:02 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: alsa-devel, kernel-janitors, Liam Girdwood, Takashi Iwai,
	Arvind Yadav, Dan Carpenter

[-- Attachment #1: Type: text/plain, Size: 371 bytes --]

On Mon, Dec 11, 2017 at 12:49:50PM +0100, Alexandre Belloni wrote:

> Maybe the good thing to do is to actaully leave the nuc900 code alone
> instead of trying to change something that never failed and that doesn't
> seem to interest anyone anymore (else the platform would have been
> converted to DT).

Yes, this definitely seems like far more trouble than it's worth.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 1/2] ASoC: nuc900: Fix platform_get_irq() error checking some more
@ 2017-12-11 12:02                   ` Mark Brown
  0 siblings, 0 replies; 30+ messages in thread
From: Mark Brown @ 2017-12-11 12:02 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: alsa-devel, kernel-janitors, Liam Girdwood, Takashi Iwai,
	Arvind Yadav, Dan Carpenter


[-- Attachment #1.1: Type: text/plain, Size: 371 bytes --]

On Mon, Dec 11, 2017 at 12:49:50PM +0100, Alexandre Belloni wrote:

> Maybe the good thing to do is to actaully leave the nuc900 code alone
> instead of trying to change something that never failed and that doesn't
> seem to interest anyone anymore (else the platform would have been
> converted to DT).

Yes, this definitely seems like far more trouble than it's worth.

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 30+ messages in thread

* Applied "ASoC: nuc900: Fix platform_get_irq() error checking some more" to the asoc tree
  2017-12-09 11:52 ` Dan Carpenter
@ 2017-12-11 12:14   ` Mark Brown
  -1 siblings, 0 replies; 30+ messages in thread
From: Mark Brown @ 2017-12-11 12:14 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Mark Brown, Liam Girdwood, Arvind Yadav, alsa-devel

The patch

   ASoC: nuc900: Fix platform_get_irq() error checking some more

has been applied to the asoc tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

From cd430a244cd5d3ca0f4053718eabdf42bc12c517 Mon Sep 17 00:00:00 2001
From: Dan Carpenter <dan.carpenter@oracle.com>
Date: Sat, 9 Dec 2017 14:52:03 +0300
Subject: [PATCH] ASoC: nuc900: Fix platform_get_irq() error checking some more

The error handling doesn't work here because "nuc900_audio->irq_num" is
unsigned.  Also we should be checking for < 0 and not <= 0 but I believe
that's harmless.  The platform_get_irq() comments don't talk about the
return values...

Fixes: fa8cc38165c2 ("ASoC: nuc900: Fix platform_get_irq's error checking")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/nuc900/nuc900-ac97.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

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)
 		goto out;
-	}
+	nuc900_audio->irq_num = ret;
 
 	nuc900_ac97_data = nuc900_audio;
 
-- 
2.15.1


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* Applied "ASoC: nuc900: Fix platform_get_irq() error checking some more" to the asoc tree
@ 2017-12-11 12:14   ` Mark Brown
  0 siblings, 0 replies; 30+ messages in thread
From: Mark Brown @ 2017-12-11 12:14 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Mark Brown, Liam Girdwood, Arvind Yadav, alsa-devel

The patch

   ASoC: nuc900: Fix platform_get_irq() error checking some more

has been applied to the asoc tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From cd430a244cd5d3ca0f4053718eabdf42bc12c517 Mon Sep 17 00:00:00 2001
From: Dan Carpenter <dan.carpenter@oracle.com>
Date: Sat, 9 Dec 2017 14:52:03 +0300
Subject: [PATCH] ASoC: nuc900: Fix platform_get_irq() error checking some more

The error handling doesn't work here because "nuc900_audio->irq_num" is
unsigned.  Also we should be checking for < 0 and not <= 0 but I believe
that's harmless.  The platform_get_irq() comments don't talk about the
return values...

Fixes: fa8cc38165c2 ("ASoC: nuc900: Fix platform_get_irq's error checking")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/nuc900/nuc900-ac97.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

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)
 		goto out;
-	}
+	nuc900_audio->irq_num = ret;
 
 	nuc900_ac97_data = nuc900_audio;
 
-- 
2.15.1


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* Re: [alsa-devel] [PATCH 1/2] ASoC: nuc900: Fix platform_get_irq() error checking some more
  2017-12-11 12:01                   ` Dan Carpenter
@ 2017-12-11 16:41                     ` Alexandre Belloni
  -1 siblings, 0 replies; 30+ messages in thread
From: Alexandre Belloni @ 2017-12-11 16:41 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Arvind Yadav, Liam Girdwood, alsa-devel, Mark Brown,
	kernel-janitors, Takashi Iwai

On 11/12/2017 at 15:01:29 +0300, Dan Carpenter wrote:
> On Mon, Dec 11, 2017 at 12:49:50PM +0100, Alexandre Belloni wrote:
> > Maybe the good thing to do is to actaully leave the nuc900 code alone
> > instead of trying to change something that never failed and that doesn't
> > seem to interest anyone anymore (else the platform would have been
> > converted to DT).
> >
> 
> I don't know.  The bug is less than a month old and this discussion has
> been useful for me as I review any platform_get_irq() changes sent to
> staging.
> 

What I meant is that the original code before this "fix" was more that 7
years old and nobody ever had any issues. And that's because getting
that IRQ on that platform will simply never fail.

Also, I really doubt anybody is going to copy paste from the nuc900-ac97
driver so I'm really wondering whether it is worth fixing this non-issue.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [alsa-devel] [PATCH 1/2] ASoC: nuc900: Fix platform_get_irq() error checking some more
@ 2017-12-11 16:41                     ` Alexandre Belloni
  0 siblings, 0 replies; 30+ messages in thread
From: Alexandre Belloni @ 2017-12-11 16:41 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Arvind Yadav, Liam Girdwood, alsa-devel, Mark Brown,
	kernel-janitors, Takashi Iwai

On 11/12/2017 at 15:01:29 +0300, Dan Carpenter wrote:
> On Mon, Dec 11, 2017 at 12:49:50PM +0100, Alexandre Belloni wrote:
> > Maybe the good thing to do is to actaully leave the nuc900 code alone
> > instead of trying to change something that never failed and that doesn't
> > seem to interest anyone anymore (else the platform would have been
> > converted to DT).
> >
> 
> I don't know.  The bug is less than a month old and this discussion has
> been useful for me as I review any platform_get_irq() changes sent to
> staging.
> 

What I meant is that the original code before this "fix" was more that 7
years old and nobody ever had any issues. And that's because getting
that IRQ on that platform will simply never fail.

Also, I really doubt anybody is going to copy paste from the nuc900-ac97
driver so I'm really wondering whether it is worth fixing this non-issue.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2017-12-11 16:41 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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.