Skip to contentSkip to conversation

serial: 8520_mtk: Prepare for platform_get_irq_optional() changes

PATCH In review Andy Shevchenko 2 participants 3 messages Dec 17, 2021 – Mar 4, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 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,

It's safe to assume that 0 is not valid IRQ in this case since the driver is only instantiated via Device Tree and corresponding OF APIs should never ever return 0 for valid IRQ. Otherwise it is a regression there.

---
v2: explained why it's safe to assume 0 is not valid here (Greg)

 drivers/tty/serial/8250/8250_mtk.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/tty/serial/8250/8250_mtk.c +2 -2
index fb65dc601b23..328ab074fd89 100644
@@ -621,7 +621,7 @@ static int __maybe_unused mtk8250_suspend(struct device *dev)
 	serial8250_suspend_port(data->line);
 
 	pinctrl_pm_select_sleep_state(dev);
-	if (irq >= 0) {
+	if (irq > 0) {
 		err = enable_irq_wake(irq);
 		if (err) {
 			dev_err(dev,
@@ -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 6 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

Quoted 7 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,

It's safe to assume that 0 is not valid IRQ in this case since the driver is only instantiated via Device Tree and corresponding OF APIs should never ever return 0 for valid IRQ. Otherwise it is a regression there.

Can it be applied now?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#2 lore raw
Quoted 10 lines · Andy Shevchenko
Quoted 9 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

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,

Quoted 6 lines
Quoted 4 lines

It's safe to assume that 0 is not valid IRQ in this case since the driver is only instantiated via Device Tree and corresponding OF APIs should never ever return 0 for valid IRQ. Otherwise it is a regression there.

Can it be applied now?

What changed to make this viable?