linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: Replace NO_IRQ by 0
@ 2022-10-06  5:15 Christophe Leroy
  2022-10-06 13:50 ` Alan Stern
  0 siblings, 1 reply; 6+ messages in thread
From: Christophe Leroy @ 2022-10-06  5:15 UTC (permalink / raw)
  To: Alan Stern, Greg Kroah-Hartman; +Cc: Christophe Leroy, linux-kernel, linux-usb

NO_IRQ is used to check the return of irq_of_parse_and_map().

On some architecture NO_IRQ is 0, on other architectures it is -1.

irq_of_parse_and_map() returns 0 on error, independent of NO_IRQ.

So use 0 instead of using NO_IRQ.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
 drivers/usb/host/ehci-grlib.c  | 2 +-
 drivers/usb/host/ehci-ppc-of.c | 2 +-
 drivers/usb/host/fhci-hcd.c    | 2 +-
 drivers/usb/host/ohci-ppc-of.c | 2 +-
 drivers/usb/host/uhci-grlib.c  | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/host/ehci-grlib.c b/drivers/usb/host/ehci-grlib.c
index a2c3b4ec8a8b..0717f2ccf49d 100644
--- a/drivers/usb/host/ehci-grlib.c
+++ b/drivers/usb/host/ehci-grlib.c
@@ -99,7 +99,7 @@ static int ehci_hcd_grlib_probe(struct platform_device *op)
 	hcd->rsrc_len = resource_size(&res);
 
 	irq = irq_of_parse_and_map(dn, 0);
-	if (irq == NO_IRQ) {
+	if (!irq) {
 		dev_err(&op->dev, "%s: irq_of_parse_and_map failed\n",
 			__FILE__);
 		rv = -EBUSY;
diff --git a/drivers/usb/host/ehci-ppc-of.c b/drivers/usb/host/ehci-ppc-of.c
index 28a19693c19f..62a0a193798c 100644
--- a/drivers/usb/host/ehci-ppc-of.c
+++ b/drivers/usb/host/ehci-ppc-of.c
@@ -119,7 +119,7 @@ static int ehci_hcd_ppc_of_probe(struct platform_device *op)
 	hcd->rsrc_len = resource_size(&res);
 
 	irq = irq_of_parse_and_map(dn, 0);
-	if (irq == NO_IRQ) {
+	if (!irq) {
 		dev_err(&op->dev, "%s: irq_of_parse_and_map failed\n",
 			__FILE__);
 		rv = -EBUSY;
diff --git a/drivers/usb/host/fhci-hcd.c b/drivers/usb/host/fhci-hcd.c
index 2ba09c3fbc2f..6d3215a3ef81 100644
--- a/drivers/usb/host/fhci-hcd.c
+++ b/drivers/usb/host/fhci-hcd.c
@@ -693,7 +693,7 @@ static int of_fhci_probe(struct platform_device *ofdev)
 
 	/* USB Host interrupt. */
 	usb_irq = irq_of_parse_and_map(node, 0);
-	if (usb_irq == NO_IRQ) {
+	if (!usb_irq) {
 		dev_err(dev, "could not get usb irq\n");
 		ret = -EINVAL;
 		goto err_usb_irq;
diff --git a/drivers/usb/host/ohci-ppc-of.c b/drivers/usb/host/ohci-ppc-of.c
index 591f675cc930..f2f6c832ec98 100644
--- a/drivers/usb/host/ohci-ppc-of.c
+++ b/drivers/usb/host/ohci-ppc-of.c
@@ -120,7 +120,7 @@ static int ohci_hcd_ppc_of_probe(struct platform_device *op)
 	}
 
 	irq = irq_of_parse_and_map(dn, 0);
-	if (irq == NO_IRQ) {
+	if (!irq) {
 		dev_err(&op->dev, "%s: irq_of_parse_and_map failed\n",
 			__FILE__);
 		rv = -EBUSY;
diff --git a/drivers/usb/host/uhci-grlib.c b/drivers/usb/host/uhci-grlib.c
index 3ef6d52839e5..907d5f01edfd 100644
--- a/drivers/usb/host/uhci-grlib.c
+++ b/drivers/usb/host/uhci-grlib.c
@@ -116,7 +116,7 @@ static int uhci_hcd_grlib_probe(struct platform_device *op)
 	hcd->rsrc_len = resource_size(&res);
 
 	irq = irq_of_parse_and_map(dn, 0);
-	if (irq == NO_IRQ) {
+	if (!irq) {
 		printk(KERN_ERR "%s: irq_of_parse_and_map failed\n", __FILE__);
 		rv = -EBUSY;
 		goto err_usb;
-- 
2.37.1


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

* Re: [PATCH] usb: Replace NO_IRQ by 0
  2022-10-06  5:15 [PATCH] usb: Replace NO_IRQ by 0 Christophe Leroy
@ 2022-10-06 13:50 ` Alan Stern
  2022-10-06 14:01   ` Christophe Leroy
  2022-10-06 14:05   ` Christophe Leroy
  0 siblings, 2 replies; 6+ messages in thread
From: Alan Stern @ 2022-10-06 13:50 UTC (permalink / raw)
  To: Christophe Leroy; +Cc: Greg Kroah-Hartman, linux-kernel, linux-usb

On Thu, Oct 06, 2022 at 07:15:44AM +0200, Christophe Leroy wrote:
> NO_IRQ is used to check the return of irq_of_parse_and_map().
> 
> On some architecture NO_IRQ is 0, on other architectures it is -1.
> 
> irq_of_parse_and_map() returns 0 on error, independent of NO_IRQ.

This isn't clear.  Does absence of an irq count as an error?  In other 
words, will irq_of_parse_and_map() sometimes return 0 and other times 
return NO_IRQ?  What about architectures on which 0 is a valid irq 
number?

> So use 0 instead of using NO_IRQ.
> 
> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
> ---
>  drivers/usb/host/ehci-grlib.c  | 2 +-
>  drivers/usb/host/ehci-ppc-of.c | 2 +-
>  drivers/usb/host/fhci-hcd.c    | 2 +-
>  drivers/usb/host/ohci-ppc-of.c | 2 +-
>  drivers/usb/host/uhci-grlib.c  | 2 +-
>  5 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/usb/host/ehci-grlib.c b/drivers/usb/host/ehci-grlib.c
> index a2c3b4ec8a8b..0717f2ccf49d 100644
> --- a/drivers/usb/host/ehci-grlib.c
> +++ b/drivers/usb/host/ehci-grlib.c
> @@ -99,7 +99,7 @@ static int ehci_hcd_grlib_probe(struct platform_device *op)
>  	hcd->rsrc_len = resource_size(&res);
>  
>  	irq = irq_of_parse_and_map(dn, 0);
> -	if (irq == NO_IRQ) {
> +	if (!irq) {
>  		dev_err(&op->dev, "%s: irq_of_parse_and_map failed\n",
>  			__FILE__);
>  		rv = -EBUSY;

Since NO_IRQ is sometimes set to -1, shouldn't this test (and all the 
other ones you changed) really be doing:

	if (!irq || irq == NO_IRQ) { ...

?

Alan Stern

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

* Re: [PATCH] usb: Replace NO_IRQ by 0
  2022-10-06 13:50 ` Alan Stern
@ 2022-10-06 14:01   ` Christophe Leroy
  2022-10-06 14:24     ` Alan Stern
  2022-10-06 14:05   ` Christophe Leroy
  1 sibling, 1 reply; 6+ messages in thread
From: Christophe Leroy @ 2022-10-06 14:01 UTC (permalink / raw)
  To: Alan Stern; +Cc: Greg Kroah-Hartman, linux-kernel, linux-usb



Le 06/10/2022 à 15:50, Alan Stern a écrit :
> On Thu, Oct 06, 2022 at 07:15:44AM +0200, Christophe Leroy wrote:
>> NO_IRQ is used to check the return of irq_of_parse_and_map().
>>
>> On some architecture NO_IRQ is 0, on other architectures it is -1.
>>
>> irq_of_parse_and_map() returns 0 on error, independent of NO_IRQ.
> 
> This isn't clear.  Does absence of an irq count as an error?  In other
> words, will irq_of_parse_and_map() sometimes return 0 and other times
> return NO_IRQ?  What about architectures on which 0 is a valid irq
> number?

NO_IRQ doesn't exist anywhere in core functions. Only some drivers and 
some architectures have relics of it.

irq_of_parse_and_map() will always return 0 on error.

0 can't be a valid logical IRQ number. It may only be a valid hwirq 
number but it will always be translated to a non-zero logical irq number.

I'm trying to get rid of NO_IRQ completely in powerpc code, therefore 
trying to clean-up all drivers used by powerpc architecture.

Long time ago Linus advocated for not using NO_IRQ, see 
https://lkml.org/lkml/2005/11/21/221

Thanks
Christophe

> 
>> So use 0 instead of using NO_IRQ.
>>
>> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
>> ---
>>   drivers/usb/host/ehci-grlib.c  | 2 +-
>>   drivers/usb/host/ehci-ppc-of.c | 2 +-
>>   drivers/usb/host/fhci-hcd.c    | 2 +-
>>   drivers/usb/host/ohci-ppc-of.c | 2 +-
>>   drivers/usb/host/uhci-grlib.c  | 2 +-
>>   5 files changed, 5 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/usb/host/ehci-grlib.c b/drivers/usb/host/ehci-grlib.c
>> index a2c3b4ec8a8b..0717f2ccf49d 100644
>> --- a/drivers/usb/host/ehci-grlib.c
>> +++ b/drivers/usb/host/ehci-grlib.c
>> @@ -99,7 +99,7 @@ static int ehci_hcd_grlib_probe(struct platform_device *op)
>>   	hcd->rsrc_len = resource_size(&res);
>>   
>>   	irq = irq_of_parse_and_map(dn, 0);
>> -	if (irq == NO_IRQ) {
>> +	if (!irq) {
>>   		dev_err(&op->dev, "%s: irq_of_parse_and_map failed\n",
>>   			__FILE__);
>>   		rv = -EBUSY;
> 
> Since NO_IRQ is sometimes set to -1, shouldn't this test (and all the
> other ones you changed) really be doing:
> 
> 	if (!irq || irq == NO_IRQ) { ...
> 
> ?
> 
> Alan Stern

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

* Re: [PATCH] usb: Replace NO_IRQ by 0
  2022-10-06 13:50 ` Alan Stern
  2022-10-06 14:01   ` Christophe Leroy
@ 2022-10-06 14:05   ` Christophe Leroy
  1 sibling, 0 replies; 6+ messages in thread
From: Christophe Leroy @ 2022-10-06 14:05 UTC (permalink / raw)
  To: Alan Stern; +Cc: Greg Kroah-Hartman, linux-kernel, linux-usb



Le 06/10/2022 à 15:50, Alan Stern a écrit :
> On Thu, Oct 06, 2022 at 07:15:44AM +0200, Christophe Leroy wrote:
>> diff --git a/drivers/usb/host/ehci-grlib.c b/drivers/usb/host/ehci-grlib.c
>> index a2c3b4ec8a8b..0717f2ccf49d 100644
>> --- a/drivers/usb/host/ehci-grlib.c
>> +++ b/drivers/usb/host/ehci-grlib.c
>> @@ -99,7 +99,7 @@ static int ehci_hcd_grlib_probe(struct platform_device *op)
>>   	hcd->rsrc_len = resource_size(&res);
>>   
>>   	irq = irq_of_parse_and_map(dn, 0);
>> -	if (irq == NO_IRQ) {
>> +	if (!irq) {
>>   		dev_err(&op->dev, "%s: irq_of_parse_and_map failed\n",
>>   			__FILE__);
>>   		rv = -EBUSY;
> 
> Since NO_IRQ is sometimes set to -1, shouldn't this test (and all the
> other ones you changed) really be doing:
> 
> 	if (!irq || irq == NO_IRQ) { ...
> 

No, because irq_of_parse_and_map() will never return -1 as an error. It 
will always be 0.

The below call gives no result.

	git grep -w NO_IRQ drivers/of/ include/

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

* Re: [PATCH] usb: Replace NO_IRQ by 0
  2022-10-06 14:01   ` Christophe Leroy
@ 2022-10-06 14:24     ` Alan Stern
  2022-11-10 17:57       ` Christophe Leroy
  0 siblings, 1 reply; 6+ messages in thread
From: Alan Stern @ 2022-10-06 14:24 UTC (permalink / raw)
  To: Christophe Leroy; +Cc: Greg Kroah-Hartman, linux-kernel, linux-usb

On Thu, Oct 06, 2022 at 02:01:57PM +0000, Christophe Leroy wrote:
> 
> 
> Le 06/10/2022 à 15:50, Alan Stern a écrit :
> > On Thu, Oct 06, 2022 at 07:15:44AM +0200, Christophe Leroy wrote:
> >> NO_IRQ is used to check the return of irq_of_parse_and_map().
> >>
> >> On some architecture NO_IRQ is 0, on other architectures it is -1.
> >>
> >> irq_of_parse_and_map() returns 0 on error, independent of NO_IRQ.
> > 
> > This isn't clear.  Does absence of an irq count as an error?  In other
> > words, will irq_of_parse_and_map() sometimes return 0 and other times
> > return NO_IRQ?  What about architectures on which 0 is a valid irq
> > number?
> 
> NO_IRQ doesn't exist anywhere in core functions. Only some drivers and 
> some architectures have relics of it.
> 
> irq_of_parse_and_map() will always return 0 on error.
> 
> 0 can't be a valid logical IRQ number. It may only be a valid hwirq 
> number but it will always be translated to a non-zero logical irq number.
> 
> I'm trying to get rid of NO_IRQ completely in powerpc code, therefore 
> trying to clean-up all drivers used by powerpc architecture.
> 
> Long time ago Linus advocated for not using NO_IRQ, see 
> https://lkml.org/lkml/2005/11/21/221

Okay, good.  Please resubmit the patch and include some of these things 
in the patch description.

Alan Stern

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

* Re: [PATCH] usb: Replace NO_IRQ by 0
  2022-10-06 14:24     ` Alan Stern
@ 2022-11-10 17:57       ` Christophe Leroy
  0 siblings, 0 replies; 6+ messages in thread
From: Christophe Leroy @ 2022-11-10 17:57 UTC (permalink / raw)
  To: Alan Stern; +Cc: Greg Kroah-Hartman, linux-kernel, linux-usb

Le 06/10/2022 à 16:24, Alan Stern a écrit :
> On Thu, Oct 06, 2022 at 02:01:57PM +0000, Christophe Leroy wrote:
>>
>>
>> Le 06/10/2022 à 15:50, Alan Stern a écrit :
>>> On Thu, Oct 06, 2022 at 07:15:44AM +0200, Christophe Leroy wrote:
>>>> NO_IRQ is used to check the return of irq_of_parse_and_map().
>>>>
>>>> On some architecture NO_IRQ is 0, on other architectures it is -1.
>>>>
>>>> irq_of_parse_and_map() returns 0 on error, independent of NO_IRQ.
>>>
>>> This isn't clear.  Does absence of an irq count as an error?  In other
>>> words, will irq_of_parse_and_map() sometimes return 0 and other times
>>> return NO_IRQ?  What about architectures on which 0 is a valid irq
>>> number?
>>
>> NO_IRQ doesn't exist anywhere in core functions. Only some drivers and
>> some architectures have relics of it.
>>
>> irq_of_parse_and_map() will always return 0 on error.
>>
>> 0 can't be a valid logical IRQ number. It may only be a valid hwirq
>> number but it will always be translated to a non-zero logical irq number.
>>
>> I'm trying to get rid of NO_IRQ completely in powerpc code, therefore
>> trying to clean-up all drivers used by powerpc architecture.
>>
>> Long time ago Linus advocated for not using NO_IRQ, see
>> https://lkml.org/lkml/2005/11/21/221
> 
> Okay, good.  Please resubmit the patch and include some of these things
> in the patch description.

I sent v2 with more details in the commit message.

Thanks
Christophe


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

end of thread, other threads:[~2022-11-10 17:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-06  5:15 [PATCH] usb: Replace NO_IRQ by 0 Christophe Leroy
2022-10-06 13:50 ` Alan Stern
2022-10-06 14:01   ` Christophe Leroy
2022-10-06 14:24     ` Alan Stern
2022-11-10 17:57       ` Christophe Leroy
2022-10-06 14:05   ` Christophe Leroy

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