Skip to contentSkip to conversation

serial/8250_dw: use platform_get_irq() instead of platform_get_resource()

PATCH In review Alexey Brodkin 2 participants 6 messages Mar 3, 2015

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

PATCH v2 1/1 serial/8250_dw: use platform_get_irq() instead of platform_get_resource()

It is not recommened to use platform_get_resource(pdev, IORESOURCE_IRQ) for requesting IRQ's resources any more, as they can be not ready yet in case of DT-booting.

platform_get_irq() instead is a recommended way for getting IRQ even if it was not retrieved earlier.

It also makes code simpler because we're getting "int" value right away and no conversion from resource to int is required.

Cc Vineet Gupta <[email protected]>
Cc Alan Cox <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Andy Shevchenko <[email protected]>

---

Changes in v2:
* Suppress error message if platform_get_irq() returns -EPROBE_DEFER

---
 drivers/tty/serial/8250/8250_dw.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/tty/serial/8250/8250_dw.c +10 -4
index e601162..cda76e8 100644
@@ -384,18 +384,24 @@ static int dw8250_probe(struct platform_device *pdev)
 {
 	struct uart_8250_port uart = {};
 	struct resource *regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	struct resource *irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+	int irq = platform_get_irq(pdev, 0);
 	struct dw8250_data *data;
 	int err;
 
-	if (!regs || !irq) {
-		dev_err(&pdev->dev, "no registers/irq defined\n");
+	if (!regs) {
+		dev_err(&pdev->dev, "no registers defined\n");
 		return -EINVAL;
 	}
 
+	if (irq < 0) {
+		if (irq != -EPROBE_DEFER)
+			dev_err(&pdev->dev, "cannot get irq\n");
+		return irq;
+	}
+
 	spin_lock_init(&uart.port.lock);
 	uart.port.mapbase = regs->start;
-	uart.port.irq = irq->start;
+	uart.port.irq = irq;
 	uart.port.handle_irq = dw8250_handle_irq;
 	uart.port.pm = dw8250_do_pm;
 	uart.port.type = PORT_8250;
Signature · 1 line
2.1.0
#1 lore raw
Quoted 15 lines · Alexey Brodkin

It is not recommened to use platform_get_resource(pdev, IORESOURCE_IRQ) for requesting IRQ's resources any more, as they can be not ready yet in case of DT-booting.

platform_get_irq() instead is a recommended way for getting IRQ even if it was not retrieved earlier.

It also makes code simpler because we're getting "int" value right away and no conversion from resource to int is required.

Cc Vineet Gupta <[email protected]>
Cc Alan Cox <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Andy Shevchenko <[email protected]>
Quoted 4 lines

---

Changes in v2:
* Suppress error message if platform_get_irq() returns -EPROBE_DEFER

Do we really need that message at all?

Quoted 38 lines
---
 drivers/tty/serial/8250/8250_dw.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/tty/serial/8250/8250_dw.c +10 -4
index e601162..cda76e8 100644
@@ -384,18 +384,24 @@ static int dw8250_probe(struct platform_device *pdev)
 {
 	struct uart_8250_port uart = {};
 	struct resource *regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	struct resource *irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+	int irq = platform_get_irq(pdev, 0);
 	struct dw8250_data *data;
 	int err;
 
-	if (!regs || !irq) {
-		dev_err(&pdev->dev, "no registers/irq defined\n");
+	if (!regs) {
+		dev_err(&pdev->dev, "no registers defined\n");
 		return -EINVAL;
 	}
 
+	if (irq < 0) {
+		if (irq != -EPROBE_DEFER)
+			dev_err(&pdev->dev, "cannot get irq\n");
+		return irq;
+	}
+
 	spin_lock_init(&uart.port.lock);
 	uart.port.mapbase = regs->start;
-	uart.port.irq = irq->start;
+	uart.port.irq = irq;
 	uart.port.handle_irq = dw8250_handle_irq;
 	uart.port.pm = dw8250_do_pm;
 	uart.port.type = PORT_8250;
Signature · 2 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy
#2 lore raw

Hi Andy,

Quoted 8 lines · Andy Shevchenko
Quoted 7 lines · Alexey Brodkin

It is not recommened to use platform_get_resource(pdev, IORESOURCE_IRQ) for requesting IRQ's resources any more, as they can be not ready yet in case of DT-booting.

platform_get_irq() instead is a recommended way for getting IRQ even if it was not retrieved earlier.

Quoted 7 lines
Quoted 5 lines

It also makes code simpler because we're getting "int" value right away and no conversion from resource to int is required.

Changes in v2:
* Suppress error message if platform_get_irq() returns -EPROBE_DEFER

Do we really need that message at all?

IMHO it makes sense.

For example it was useful for me when debugging stacked interrupt controllers setup - I got explicitly notified why this particular device failed on probe.

Note that IRQ is a pretty specific resource due to the fact of INTC stacking and situations when each and every INTC gets finally probed.

Still if you believe we may drop this message with no loss of usability
- I'm fine with that as well.

-Alexey

#3 lore raw
Quoted 17 lines · Alexey Brodkin

Hi Andy,

Quoted 14 lines · Andy Shevchenko
Quoted 12 lines · Alexey Brodkin

It is not recommened to use platform_get_resource(pdev, IORESOURCE_IRQ) for requesting IRQ's resources any more, as they can be not ready yet in case of DT-booting.

platform_get_irq() instead is a recommended way for getting IRQ even if it was not retrieved earlier.

It also makes code simpler because we're getting "int" value right away and no conversion from resource to int is required.

Changes in v2:
* Suppress error message if platform_get_irq() returns -EPROBE_DEFER

Quoted 7 lines
Quoted 1 line

Do we really need that message at all?

IMHO it makes sense.

For example it was useful for me when debugging stacked interrupt controllers setup - I got explicitly notified why this particular device failed on probe.

There are so many device drivers which prints similar message that you would consider to make a separate patch to platform.c code to do that stuff there once for all.

Quoted 5 lines

Note that IRQ is a pretty specific resource due to the fact of INTC stacking and situations when each and every INTC gets finally probed.

Still if you believe we may drop this message with no loss of usability
- I'm fine with that as well.

If no one else has an objection I would prefer to skip it. You always may get the return code from probe(), though it's not exactly mapped to the reason why it failed.

Signature · 2 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy
#4 lore raw

Hi Andy,

Quoted 33 lines · Andy Shevchenko
Quoted 17 lines · Alexey Brodkin

Hi Andy,

Quoted 14 lines · Andy Shevchenko
Quoted 12 lines · Alexey Brodkin

It is not recommened to use platform_get_resource(pdev, IORESOURCE_IRQ) for requesting IRQ's resources any more, as they can be not ready yet in case of DT-booting.

platform_get_irq() instead is a recommended way for getting IRQ even if it was not retrieved earlier.

It also makes code simpler because we're getting "int" value right away and no conversion from resource to int is required.

Changes in v2:
* Suppress error message if platform_get_irq() returns -EPROBE_DEFER

Quoted 7 lines
Quoted 1 line

Do we really need that message at all?

IMHO it makes sense.

For example it was useful for me when debugging stacked interrupt controllers setup - I got explicitly notified why this particular device failed on probe.

There are so many device drivers which prints similar message that you would consider to make a separate patch to platform.c code to do that stuff there once for all.

Quoted 3 lines

Note that IRQ is a pretty specific resource due to the fact of INTC stacking and situations when each and every INTC gets finally probed.

Quoted 6 lines
Quoted 2 lines

Still if you believe we may drop this message with no loss of usability
- I'm fine with that as well.

If no one else has an objection I would prefer to skip it. You always may get the return code from probe(), though it's not exactly mapped to the reason why it failed.

Then we may want to do another massive clean-up because there're lots of other drivers that have this message in some form :)

-Alexey

#5 lore raw
Quoted 10 lines · Alexey Brodkin
Quoted 7 lines
Quoted 3 lines

For example it was useful for me when debugging stacked interrupt controllers setup - I got explicitly notified why this particular device failed on probe.

There are so many device drivers which prints similar message that you would consider to make a separate patch to platform.c code to do that stuff there once for all.

Then we may want to do another massive clean-up because there're lots of other drivers that have this message in some form :)

Yeah, you may do that and it will be (by my opinion) more useful than introducing one more place with the duplicate message.

Signature · 2 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy