Skip to contentSkip to conversation

serial: 8520_mtk: Prepare for platform_get_irq_optional() changes

PATCH Superseded Andy Shevchenko 2 participants 3 messages Dec 17, 2021

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 serial: 8520_mtk: Prepare for platform_get_irq_optional() changes

The platform_get_irq_optional() is going to be changed in a way that the result of it:
= 0 means no IRQ is provided
< 0 means the error which needs to be propagated to the upper layers

Quoted 1 line

0 valid vIRQ is allocated

In this case, drop check for 0. Note, the 0 is not valid vIRQ and platform_get_irq_optional() issues a big WARN() in such case,

---
 drivers/tty/serial/8250/8250_mtk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/8250/8250_mtk.c +1 -1
index fb65dc601b23..8d3e16d7bf63 100644
@@ -641,7 +641,7 @@ static int __maybe_unused mtk8250_resume(struct device *dev)
 	struct mtk8250_data *data = dev_get_drvdata(dev);
 	int irq = data->rx_wakeup_irq;
 
-	if (irq >= 0)
+	if (irq > 0)
 		disable_irq_wake(irq);
 	pinctrl_pm_select_default_state(dev);
 
Signature · 1 line
2.34.1
#1 lore raw
Quoted 5 lines · Andy Shevchenko

The platform_get_irq_optional() is going to be changed in a way that the result of it:
= 0 means no IRQ is provided
< 0 means the error which needs to be propagated to the upper layers

Quoted 1 line

0 valid vIRQ is allocated

What about 0 being a valid irq?

Quoted 2 lines

In this case, drop check for 0. Note, the 0 is not valid vIRQ and platform_get_irq_optional() issues a big WARN() in such case,

But it still is a valid irq, so why did you just break things? Yes, a warning will happen, but the driver and platform will still work.

Quoted 11 lines
---
 drivers/tty/serial/8250/8250_mtk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/8250/8250_mtk.c +0 -0
index fb65dc601b23..8d3e16d7bf63 100644

drivers/tty/serial/8250/8250_mtk.c static int __maybe_unused mtk8250_resume(struct device *dev) · line 645

Quoted 6 lines
drivers/tty/serial/8250/8250_mtk.c +1 -1
@@ -641,7 +641,7 @@ static int __maybe_unused mtk8250_resume(struct device *dev)
 	struct mtk8250_data *data = dev_get_drvdata(dev);
 	int irq = data->rx_wakeup_irq;
 
-	if (irq >= 0)
+	if (irq > 0)
 		disable_irq_wake(irq);

Why change this now? What does this solve at this point in time?

thanks,

greg k-h

#2 lore raw
Quoted 8 lines · Greg Kroah-Hartman
Quoted 5 lines · Andy Shevchenko

The platform_get_irq_optional() is going to be changed in a way that the result of it:
= 0 means no IRQ is provided
< 0 means the error which needs to be propagated to the upper layers

Quoted 1 line

0 valid vIRQ is allocated

What about 0 being a valid irq?

For this driver it can't be possible. The driver is instantiated via DT only and OF APIs never return 0 for IRQ. If it's the case, it's a regression in the OF APIs.

I can elaborate in the commit message.

Quoted 5 lines
Quoted 2 lines

In this case, drop check for 0. Note, the 0 is not valid vIRQ and platform_get_irq_optional() issues a big WARN() in such case,

But it still is a valid irq, so why did you just break things? Yes, a warning will happen, but the driver and platform will still work.

In general yes, but not in this case. See above.

...

Quoted 5 lines

drivers/tty/serial/8250/8250_mtk.c static int __maybe_unused mtk8250_resume(struct device *dev) · line 645

Quoted 3 lines
drivers/tty/serial/8250/8250_mtk.c +1 -1
-	if (irq >= 0)
+	if (irq > 0)
 		disable_irq_wake(irq);

Why change this now? What does this solve at this point in time?

As explained in the commit message, it's a preparation patch to fix the logic behind platform_get_irq_optional().

Signature · 2 lines
With Best Regards,
Andy Shevchenko