linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: cdns3: remove dead code
@ 2022-09-26 13:59 Dongliang Mu
  2022-09-28  6:40 ` Pawel Laszczak
  2022-09-28  6:49 ` Roger Quadros
  0 siblings, 2 replies; 6+ messages in thread
From: Dongliang Mu @ 2022-09-26 13:59 UTC (permalink / raw)
  To: Peter Chen, Pawel Laszczak, Roger Quadros, Aswath Govindraju,
	Greg Kroah-Hartman
  Cc: Dongliang Mu, linux-usb, linux-kernel

From: Dongliang Mu <mudongliangabcd@gmail.com>

Smatch reports the following error:

drivers/usb/cdns3/cdns3-plat.c:113 cdns3_plat_probe() warn:
platform_get_irq() does not return zero

From the document, platform_get_irq_byname_optional only returns
non-zero value, and negative value on failure.

Fix this by removing the zero value checking.

Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
---
 drivers/usb/cdns3/cdns3-plat.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/usb/cdns3/cdns3-plat.c b/drivers/usb/cdns3/cdns3-plat.c
index dc068e940ed5..2bc5d094548b 100644
--- a/drivers/usb/cdns3/cdns3-plat.c
+++ b/drivers/usb/cdns3/cdns3-plat.c
@@ -110,8 +110,6 @@ static int cdns3_plat_probe(struct platform_device *pdev)
 	cdns->wakeup_irq = platform_get_irq_byname_optional(pdev, "wakeup");
 	if (cdns->wakeup_irq == -EPROBE_DEFER)
 		return cdns->wakeup_irq;
-	else if (cdns->wakeup_irq == 0)
-		return -EINVAL;
 
 	if (cdns->wakeup_irq < 0) {
 		dev_dbg(dev, "couldn't get wakeup irq\n");
-- 
2.35.1


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

* RE: [PATCH] usb: cdns3: remove dead code
  2022-09-26 13:59 [PATCH] usb: cdns3: remove dead code Dongliang Mu
@ 2022-09-28  6:40 ` Pawel Laszczak
  2022-09-28  6:49   ` Roger Quadros
  2022-09-28  6:49 ` Roger Quadros
  1 sibling, 1 reply; 6+ messages in thread
From: Pawel Laszczak @ 2022-09-28  6:40 UTC (permalink / raw)
  To: Dongliang Mu, Peter Chen, Roger Quadros, Aswath Govindraju,
	Greg Kroah-Hartman
  Cc: Dongliang Mu, linux-usb, linux-kernel

>
>From: Dongliang Mu <mudongliangabcd@gmail.com>
>
>Smatch reports the following error:
>
>drivers/usb/cdns3/cdns3-plat.c:113 cdns3_plat_probe() warn:
>platform_get_irq() does not return zero
>
>From the document, platform_get_irq_byname_optional only returns
>non-zero value, and negative value on failure.
>
>Fix this by removing the zero value checking.
>
>Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
>---
> drivers/usb/cdns3/cdns3-plat.c | 2 --
> 1 file changed, 2 deletions(-)
>
>diff --git a/drivers/usb/cdns3/cdns3-plat.c b/drivers/usb/cdns3/cdns3-plat.c
>index dc068e940ed5..2bc5d094548b 100644
>--- a/drivers/usb/cdns3/cdns3-plat.c
>+++ b/drivers/usb/cdns3/cdns3-plat.c
>@@ -110,8 +110,6 @@ static int cdns3_plat_probe(struct platform_device *pdev)
> 	cdns->wakeup_irq = platform_get_irq_byname_optional(pdev, "wakeup");
> 	if (cdns->wakeup_irq == -EPROBE_DEFER)
> 		return cdns->wakeup_irq;
>-	else if (cdns->wakeup_irq == 0)
>-		return -EINVAL;
>
I think that here we should have:
	else if (cdns->wakeup_irq == -ENXIO)
		return -EINVAL;
 because of function: 
platform_get_irq_byname_optional -> __platform_get_irq_byname returns
irq number (>0),  -EPROBE_DEFFER or -ENXIO


thanks
Pawel

> 	if (cdns->wakeup_irq < 0) {
> 		dev_dbg(dev, "couldn't get wakeup irq\n");
>--
>2.35.1


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

* Re: [PATCH] usb: cdns3: remove dead code
  2022-09-28  6:40 ` Pawel Laszczak
@ 2022-09-28  6:49   ` Roger Quadros
  2022-09-28  6:57     ` Dongliang Mu
  0 siblings, 1 reply; 6+ messages in thread
From: Roger Quadros @ 2022-09-28  6:49 UTC (permalink / raw)
  To: Pawel Laszczak, Dongliang Mu, Peter Chen, Aswath Govindraju,
	Greg Kroah-Hartman
  Cc: Dongliang Mu, linux-usb, linux-kernel

Hello Pawel,

On 28/09/2022 09:40, Pawel Laszczak wrote:
>>
>> From: Dongliang Mu <mudongliangabcd@gmail.com>
>>
>> Smatch reports the following error:
>>
>> drivers/usb/cdns3/cdns3-plat.c:113 cdns3_plat_probe() warn:
>> platform_get_irq() does not return zero
>>
>>From the document, platform_get_irq_byname_optional only returns
>> non-zero value, and negative value on failure.
>>
>> Fix this by removing the zero value checking.
>>
>> Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
>> ---
>> drivers/usb/cdns3/cdns3-plat.c | 2 --
>> 1 file changed, 2 deletions(-)
>>
>> diff --git a/drivers/usb/cdns3/cdns3-plat.c b/drivers/usb/cdns3/cdns3-plat.c
>> index dc068e940ed5..2bc5d094548b 100644
>> --- a/drivers/usb/cdns3/cdns3-plat.c
>> +++ b/drivers/usb/cdns3/cdns3-plat.c
>> @@ -110,8 +110,6 @@ static int cdns3_plat_probe(struct platform_device *pdev)
>> 	cdns->wakeup_irq = platform_get_irq_byname_optional(pdev, "wakeup");
>> 	if (cdns->wakeup_irq == -EPROBE_DEFER)
>> 		return cdns->wakeup_irq;
>> -	else if (cdns->wakeup_irq == 0)
>> -		return -EINVAL;
>>
> I think that here we should have:
> 	else if (cdns->wakeup_irq == -ENXIO)
> 		return -EINVAL;
>  because of function: 
> platform_get_irq_byname_optional -> __platform_get_irq_byname returns
> irq number (>0),  -EPROBE_DEFFER or -ENXIO

But this is changing functionality and should come as a new patch.

The original patch is correct as it doesn't change existing code
functionality.

> 
> 
> thanks
> Pawel
> 
>> 	if (cdns->wakeup_irq < 0) {
>> 		dev_dbg(dev, "couldn't get wakeup irq\n");
>> --
>> 2.35.1
> 

cheers,
-roger

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

* Re: [PATCH] usb: cdns3: remove dead code
  2022-09-26 13:59 [PATCH] usb: cdns3: remove dead code Dongliang Mu
  2022-09-28  6:40 ` Pawel Laszczak
@ 2022-09-28  6:49 ` Roger Quadros
  2022-09-28  7:04   ` Dongliang Mu
  1 sibling, 1 reply; 6+ messages in thread
From: Roger Quadros @ 2022-09-28  6:49 UTC (permalink / raw)
  To: Dongliang Mu, Peter Chen, Pawel Laszczak, Aswath Govindraju,
	Greg Kroah-Hartman
  Cc: Dongliang Mu, linux-usb, linux-kernel



On 26/09/2022 16:59, Dongliang Mu wrote:
> From: Dongliang Mu <mudongliangabcd@gmail.com>
> 
> Smatch reports the following error:
> 
> drivers/usb/cdns3/cdns3-plat.c:113 cdns3_plat_probe() warn:
> platform_get_irq() does not return zero
> 
> From the document, platform_get_irq_byname_optional only returns
> non-zero value, and negative value on failure.
> 
> Fix this by removing the zero value checking.
> 
> Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>

Reviewed-by: Roger Quadros <rogerq@kernel.org>

> ---
>  drivers/usb/cdns3/cdns3-plat.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/drivers/usb/cdns3/cdns3-plat.c b/drivers/usb/cdns3/cdns3-plat.c
> index dc068e940ed5..2bc5d094548b 100644
> --- a/drivers/usb/cdns3/cdns3-plat.c
> +++ b/drivers/usb/cdns3/cdns3-plat.c
> @@ -110,8 +110,6 @@ static int cdns3_plat_probe(struct platform_device *pdev)
>  	cdns->wakeup_irq = platform_get_irq_byname_optional(pdev, "wakeup");
>  	if (cdns->wakeup_irq == -EPROBE_DEFER)
>  		return cdns->wakeup_irq;
> -	else if (cdns->wakeup_irq == 0)
> -		return -EINVAL;
>  
>  	if (cdns->wakeup_irq < 0) {
>  		dev_dbg(dev, "couldn't get wakeup irq\n");


cheers,
-roger

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

* Re: [PATCH] usb: cdns3: remove dead code
  2022-09-28  6:49   ` Roger Quadros
@ 2022-09-28  6:57     ` Dongliang Mu
  0 siblings, 0 replies; 6+ messages in thread
From: Dongliang Mu @ 2022-09-28  6:57 UTC (permalink / raw)
  To: Roger Quadros
  Cc: Pawel Laszczak, Dongliang Mu, Peter Chen, Aswath Govindraju,
	Greg Kroah-Hartman, linux-usb, linux-kernel

On Wed, Sep 28, 2022 at 2:49 PM Roger Quadros <rogerq@kernel.org> wrote:
>
> Hello Pawel,
>
> On 28/09/2022 09:40, Pawel Laszczak wrote:
> >>
> >> From: Dongliang Mu <mudongliangabcd@gmail.com>
> >>
> >> Smatch reports the following error:
> >>
> >> drivers/usb/cdns3/cdns3-plat.c:113 cdns3_plat_probe() warn:
> >> platform_get_irq() does not return zero
> >>
> >>From the document, platform_get_irq_byname_optional only returns
> >> non-zero value, and negative value on failure.
> >>
> >> Fix this by removing the zero value checking.
> >>
> >> Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
> >> ---
> >> drivers/usb/cdns3/cdns3-plat.c | 2 --
> >> 1 file changed, 2 deletions(-)
> >>
> >> diff --git a/drivers/usb/cdns3/cdns3-plat.c b/drivers/usb/cdns3/cdns3-plat.c
> >> index dc068e940ed5..2bc5d094548b 100644
> >> --- a/drivers/usb/cdns3/cdns3-plat.c
> >> +++ b/drivers/usb/cdns3/cdns3-plat.c
> >> @@ -110,8 +110,6 @@ static int cdns3_plat_probe(struct platform_device *pdev)
> >>      cdns->wakeup_irq = platform_get_irq_byname_optional(pdev, "wakeup");
> >>      if (cdns->wakeup_irq == -EPROBE_DEFER)
> >>              return cdns->wakeup_irq;
> >> -    else if (cdns->wakeup_irq == 0)
> >> -            return -EINVAL;
> >>
> > I think that here we should have:
> >       else if (cdns->wakeup_irq == -ENXIO)
> >               return -EINVAL;
> >  because of function:
> > platform_get_irq_byname_optional -> __platform_get_irq_byname returns
> > irq number (>0),  -EPROBE_DEFFER or -ENXIO
>
> But this is changing functionality and should come as a new patch.

I agree. Pawel, you should submit a new patch. This satisfies the rule
of kernel patching.

>
> The original patch is correct as it doesn't change existing code
> functionality.
>
> >
> >
> > thanks
> > Pawel
> >
> >>      if (cdns->wakeup_irq < 0) {
> >>              dev_dbg(dev, "couldn't get wakeup irq\n");
> >> --
> >> 2.35.1
> >
>
> cheers,
> -roger

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

* Re: [PATCH] usb: cdns3: remove dead code
  2022-09-28  6:49 ` Roger Quadros
@ 2022-09-28  7:04   ` Dongliang Mu
  0 siblings, 0 replies; 6+ messages in thread
From: Dongliang Mu @ 2022-09-28  7:04 UTC (permalink / raw)
  To: Roger Quadros
  Cc: Dongliang Mu, Peter Chen, Pawel Laszczak, Aswath Govindraju,
	Greg Kroah-Hartman, linux-usb, linux-kernel

On Wed, Sep 28, 2022 at 2:50 PM Roger Quadros <rogerq@kernel.org> wrote:
>
>
>
> On 26/09/2022 16:59, Dongliang Mu wrote:
> > From: Dongliang Mu <mudongliangabcd@gmail.com>
> >
> > Smatch reports the following error:
> >
> > drivers/usb/cdns3/cdns3-plat.c:113 cdns3_plat_probe() warn:
> > platform_get_irq() does not return zero
> >
> > From the document, platform_get_irq_byname_optional only returns
> > non-zero value, and negative value on failure.
> >
> > Fix this by removing the zero value checking.
> >
> > Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
>
> Reviewed-by: Roger Quadros <rogerq@kernel.org>

Hi Roger,

By simply checking the usage of API - platform_get_irq_byname_optional,
there are several issues in other code sites.

However, some code sites are related to semantics. I will analyze all
of them and submit patches later.

>
> > ---
> >  drivers/usb/cdns3/cdns3-plat.c | 2 --
> >  1 file changed, 2 deletions(-)
> >
> > diff --git a/drivers/usb/cdns3/cdns3-plat.c b/drivers/usb/cdns3/cdns3-plat.c
> > index dc068e940ed5..2bc5d094548b 100644
> > --- a/drivers/usb/cdns3/cdns3-plat.c
> > +++ b/drivers/usb/cdns3/cdns3-plat.c
> > @@ -110,8 +110,6 @@ static int cdns3_plat_probe(struct platform_device *pdev)
> >       cdns->wakeup_irq = platform_get_irq_byname_optional(pdev, "wakeup");
> >       if (cdns->wakeup_irq == -EPROBE_DEFER)
> >               return cdns->wakeup_irq;
> > -     else if (cdns->wakeup_irq == 0)
> > -             return -EINVAL;
> >
> >       if (cdns->wakeup_irq < 0) {
> >               dev_dbg(dev, "couldn't get wakeup irq\n");
>
>
> cheers,
> -roger

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

end of thread, other threads:[~2022-09-28  7:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-26 13:59 [PATCH] usb: cdns3: remove dead code Dongliang Mu
2022-09-28  6:40 ` Pawel Laszczak
2022-09-28  6:49   ` Roger Quadros
2022-09-28  6:57     ` Dongliang Mu
2022-09-28  6:49 ` Roger Quadros
2022-09-28  7:04   ` Dongliang Mu

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).