diff mbox series

[v4,4/7] pinctrl: wpcm450: elax return value check for IRQ get

Message ID 2d89de999a1d142efbd5eb10ff31cca12309e66d.1684220962.git.mazziesaccount@gmail.com (mailing list archive)
State Handled Elsewhere
Headers show
Series fix fwnode_irq_get[_byname()] returnvalue | expand

Commit Message

Matti Vaittinen May 16, 2023, 7:13 a.m. UTC
fwnode_irq_get[_byname]() were changed to not return 0 anymore. The
special error case where device-tree based IRQ mapping fails can't no
longer be reliably detected from this return value. This yields a
functional change in the driver where the mapping failure is treated as
an error.

The mapping failure can occur for example when the device-tree IRQ
information translation call-back(s) (xlate) fail, IRQ domain is not
found, IRQ type conflicts, etc. In most cases this indicates an error in
the device-tree and special handling is not really required.

One more thing to note is that ACPI APIs do not return zero for any
failures so this special handling did only apply on device-tree based
systems.

Drop the special (no error, just skip the IRQ) handling for DT mapping
failures as these can no longer be separated from other errors at driver
side.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>

---

The special handling in this driver was added when fixing a problem
where returning zero from fwnode_irq_get[_byname]() was treated as
succes yielding zero being used as a valid IRQ by the driver.
f4a31facfa80 ("pinctrl: wpcm450: Correct the fwnode_irq_get() return value check")
The commit message does not mention if choosing not to abort the probe
on device-tree mapping failure (as is done on other errors) was chosen
because: a) Abort would have broken some existing setup. b) Because skipping
an IRQ on failure is "the right thing to do", or c) because it sounded like
a way to minimize risk of breaking something.

If the reason is a) - then I'd appreciate receiving some more
information and a suggestion how to proceed (if possible). If the reason
is b), then it might be best to just skip the IRQ instead of aborting
the probe for all errors on IRQ getting. Finally, in case of c), well,
by acking this change you will now accept the risk :)

The first patch of the series changes the fwnode_irq_get() so this depends
on the first patch of the series and should not be applied alone.
---
 drivers/pinctrl/nuvoton/pinctrl-wpcm450.c | 2 --
 1 file changed, 2 deletions(-)

Comments

Jonathan Neuschäfer May 16, 2023, 4:32 p.m. UTC | #1
Hello,

> [PATCH v4 4/7] pinctrl: wpcm450: elax return value check for IRQ get

Typo ("elax") in the subject line.

>
On Tue, May 16, 2023 at 10:13:14AM +0300, Matti Vaittinen wrote:
> fwnode_irq_get[_byname]() were changed to not return 0 anymore. The
> special error case where device-tree based IRQ mapping fails can't no
> longer be reliably detected from this return value. This yields a
> functional change in the driver where the mapping failure is treated as
> an error.
> 
> The mapping failure can occur for example when the device-tree IRQ
> information translation call-back(s) (xlate) fail, IRQ domain is not
> found, IRQ type conflicts, etc. In most cases this indicates an error in
> the device-tree and special handling is not really required.
> 
> One more thing to note is that ACPI APIs do not return zero for any
> failures so this special handling did only apply on device-tree based
> systems.
> 
> Drop the special (no error, just skip the IRQ) handling for DT mapping
> failures as these can no longer be separated from other errors at driver
> side.
> 
> Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
> 
> ---
> 
> The special handling in this driver was added when fixing a problem
> where returning zero from fwnode_irq_get[_byname]() was treated as
> succes yielding zero being used as a valid IRQ by the driver.
> f4a31facfa80 ("pinctrl: wpcm450: Correct the fwnode_irq_get() return value check")
> The commit message does not mention if choosing not to abort the probe
> on device-tree mapping failure (as is done on other errors) was chosen
> because: a) Abort would have broken some existing setup. b) Because skipping
> an IRQ on failure is "the right thing to do", or c) because it sounded like
> a way to minimize risk of breaking something.
> 
> If the reason is a) - then I'd appreciate receiving some more
> information and a suggestion how to proceed (if possible). If the reason
> is b), then it might be best to just skip the IRQ instead of aborting
> the probe for all errors on IRQ getting. Finally, in case of c), well,
> by acking this change you will now accept the risk :)
> 
> The first patch of the series changes the fwnode_irq_get() so this depends
> on the first patch of the series and should not be applied alone.

Thanks for investigating this!

It's not a), because there are no existing setups that rely on broken
IRQs connected to this pinctrl/GPIO controller.

I suspect b) or c), but I'll let Andy give a more definite answer.

> ---
>  drivers/pinctrl/nuvoton/pinctrl-wpcm450.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c b/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c
> index 2d1c1652cfd9..f9326210b5eb 100644
> --- a/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c
> +++ b/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c
> @@ -1106,8 +1106,6 @@ static int wpcm450_gpio_register(struct platform_device *pdev,
>  			irq = fwnode_irq_get(child, i);
>  			if (irq < 0)
>  				break;
> -			if (!irq)
> -				continue;
>  
>  			girq->parents[i] = irq;
>  			girq->num_parents++;

Anyway, this looks good to me.

Reviewed-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Vaittinen, Matti May 17, 2023, 5:41 a.m. UTC | #2
Thanks for taking a look at this Jonathan.

On 5/16/23 19:32, Jonathan Neuschäfer wrote:
> Hello,
> 
>> [PATCH v4 4/7] pinctrl: wpcm450: elax return value check for IRQ get
> 
> Typo ("elax") in the subject line.

It mut've ben the leter eatng moster :)

I'll take care of this when re-spinning.

> On Tue, May 16, 2023 at 10:13:14AM +0300, Matti Vaittinen wrote:
>> The special handling in this driver was added when fixing a problem
>> where returning zero from fwnode_irq_get[_byname]() was treated as
>> succes yielding zero being used as a valid IRQ by the driver.
>> f4a31facfa80 ("pinctrl: wpcm450: Correct the fwnode_irq_get() return value check")
>> The commit message does not mention if choosing not to abort the probe
>> on device-tree mapping failure (as is done on other errors) was chosen
>> because: a) Abort would have broken some existing setup. b) Because skipping
>> an IRQ on failure is "the right thing to do", or c) because it sounded like
>> a way to minimize risk of breaking something.
>>
>> If the reason is a) - then I'd appreciate receiving some more
>> information and a suggestion how to proceed (if possible). If the reason
>> is b), then it might be best to just skip the IRQ instead of aborting
>> the probe for all errors on IRQ getting. Finally, in case of c), well,
>> by acking this change you will now accept the risk :)
>>
>> The first patch of the series changes the fwnode_irq_get() so this depends
>> on the first patch of the series and should not be applied alone.
> 
> Thanks for investigating this!
> 
> It's not a), because there are no existing setups that rely on broken
> IRQs connected to this pinctrl/GPIO controller.

Glad to know. Then we should be able to "unify" the error handling no 
matter what fails when IRQ is tried to be obtained. Either by always 
aborting the probe or by skipping the broken IRQs.

> I suspect b) or c), but I'll let Andy give a more definite answer.
> 
>> ---
>>   drivers/pinctrl/nuvoton/pinctrl-wpcm450.c | 2 --
>>   1 file changed, 2 deletions(-)
>>
>> diff --git a/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c b/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c
>> index 2d1c1652cfd9..f9326210b5eb 100644
>> --- a/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c
>> +++ b/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c
>> @@ -1106,8 +1106,6 @@ static int wpcm450_gpio_register(struct platform_device *pdev,
>>   			irq = fwnode_irq_get(child, i);
>>   			if (irq < 0)
>>   				break;
>> -			if (!irq)
>> -				continue;
>>   
>>   			girq->parents[i] = irq;
>>   			girq->num_parents++;
> 
> Anyway, this looks good to me.
> 
> Reviewed-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>

Yours,
	-- Matti
Andy Shevchenko May 17, 2023, 5:03 p.m. UTC | #3
On Tue, May 16, 2023 at 06:32:09PM +0200, Jonathan Neuschäfer wrote:
> On Tue, May 16, 2023 at 10:13:14AM +0300, Matti Vaittinen wrote:

> > The special handling in this driver was added when fixing a problem
> > where returning zero from fwnode_irq_get[_byname]() was treated as
> > succes yielding zero being used as a valid IRQ by the driver.
> > f4a31facfa80 ("pinctrl: wpcm450: Correct the fwnode_irq_get() return value check")
> > The commit message does not mention if choosing not to abort the probe
> > on device-tree mapping failure (as is done on other errors) was chosen
> > because: a) Abort would have broken some existing setup. b) Because skipping
> > an IRQ on failure is "the right thing to do", or c) because it sounded like
> > a way to minimize risk of breaking something.
> > 
> > If the reason is a) - then I'd appreciate receiving some more
> > information and a suggestion how to proceed (if possible). If the reason
> > is b), then it might be best to just skip the IRQ instead of aborting
> > the probe for all errors on IRQ getting. Finally, in case of c), well,
> > by acking this change you will now accept the risk :)

From my side it was c).

> > The first patch of the series changes the fwnode_irq_get() so this depends
> > on the first patch of the series and should not be applied alone.
> 
> Thanks for investigating this!
> 
> It's not a), because there are no existing setups that rely on broken
> IRQs connected to this pinctrl/GPIO controller.
> 
> I suspect b) or c), but I'll let Andy give a more definite answer.
diff mbox series

Patch

diff --git a/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c b/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c
index 2d1c1652cfd9..f9326210b5eb 100644
--- a/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c
+++ b/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c
@@ -1106,8 +1106,6 @@  static int wpcm450_gpio_register(struct platform_device *pdev,
 			irq = fwnode_irq_get(child, i);
 			if (irq < 0)
 				break;
-			if (!irq)
-				continue;
 
 			girq->parents[i] = irq;
 			girq->num_parents++;