linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/10] serial: Use platform_get_irq*() variants to fetch IRQ's
@ 2021-12-24 14:29 Lad Prabhakar
  2021-12-24 14:29 ` [PATCH 01/10] serial: altera: Use platform_get_irq_optional() to get the interrupt Lad Prabhakar
                   ` (9 more replies)
  0 siblings, 10 replies; 16+ messages in thread
From: Lad Prabhakar @ 2021-12-24 14:29 UTC (permalink / raw)
  To: linux-serial; +Cc: Rob Herring, linux-kernel, Prabhakar, Lad Prabhakar

Hi All,

This patch series aims to drop using platform_get_resource() for IRQ types
in preparation for removal of static setup of IRQ resource from DT core
code.

Dropping usage of platform_get_resource() was agreed based on
the discussion [0].

[0] https://patchwork.kernel.org/project/linux-renesas-soc/
patch/20211209001056.29774-1-prabhakar.mahadev-lad.rj@bp.renesas.com/

Cheers,
Prabhakar

Lad Prabhakar (10):
  serial: altera: Use platform_get_irq_optional() to get the interrupt
  serial: 8250_bcm7271: Use platform_get_irq() to get the interrupt
  serial: 8250_bcm7271: Propagate error codes from brcmuart_probe()
  serial: meson: Use platform_get_irq() to get the interrupt
  serial: pxa: Use platform_get_irq() to get the interrupt
  serial: altera_jtaguart: Use platform_get_irq_optional() to get the
    interrupt
  serial: vt8500: Use platform_get_irq() to get the interrupt
  serial: ar933x: Use platform_get_irq() to get the interrupt
  serial: bcm63xx: Use platform_get_irq() to get the interrupt
  serial: pmac_zilog: Use platform_get_irq() to get the interrupt

 drivers/tty/serial/8250/8250_bcm7271.c | 23 +++++++++++++----------
 drivers/tty/serial/altera_jtaguart.c   | 11 +++++++----
 drivers/tty/serial/altera_uart.c       |  9 +++++----
 drivers/tty/serial/ar933x_uart.c       | 12 +++++-------
 drivers/tty/serial/bcm63xx_uart.c      | 10 +++++-----
 drivers/tty/serial/meson_uart.c        | 11 ++++++-----
 drivers/tty/serial/pmac_zilog.c        | 12 ++++++++----
 drivers/tty/serial/pxa.c               | 12 ++++++++----
 drivers/tty/serial/vt8500_serial.c     | 12 ++++++++----
 9 files changed, 65 insertions(+), 47 deletions(-)

-- 
2.17.1


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

* [PATCH 01/10] serial: altera: Use platform_get_irq_optional() to get the interrupt
  2021-12-24 14:29 [PATCH 00/10] serial: Use platform_get_irq*() variants to fetch IRQ's Lad Prabhakar
@ 2021-12-24 14:29 ` Lad Prabhakar
  2021-12-24 14:29 ` [PATCH 02/10] serial: 8250_bcm7271: Use platform_get_irq() " Lad Prabhakar
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 16+ messages in thread
From: Lad Prabhakar @ 2021-12-24 14:29 UTC (permalink / raw)
  To: linux-serial, Tobias Klauser, Greg Kroah-Hartman, Jiri Slaby
  Cc: Rob Herring, linux-kernel, Prabhakar, Lad Prabhakar

platform_get_resource(pdev, IORESOURCE_IRQ, ..) relies on static
allocation of IRQ resources in DT core code, this causes an issue
when using hierarchical interrupt domains using "interrupts" property
in the node as this bypasses the hierarchical setup and messes up the
irq chaining.

In preparation for removal of static setup of IRQ resource from DT core
code use platform_get_irq_optional().

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
 drivers/tty/serial/altera_uart.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/serial/altera_uart.c b/drivers/tty/serial/altera_uart.c
index 7c5f4e966b59..64a352b40197 100644
--- a/drivers/tty/serial/altera_uart.c
+++ b/drivers/tty/serial/altera_uart.c
@@ -553,7 +553,6 @@ static int altera_uart_probe(struct platform_device *pdev)
 	struct altera_uart_platform_uart *platp = dev_get_platdata(&pdev->dev);
 	struct uart_port *port;
 	struct resource *res_mem;
-	struct resource *res_irq;
 	int i = pdev->id;
 	int ret;
 
@@ -577,9 +576,11 @@ static int altera_uart_probe(struct platform_device *pdev)
 	else
 		return -EINVAL;
 
-	res_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
-	if (res_irq)
-		port->irq = res_irq->start;
+	ret = platform_get_irq_optional(pdev, 0);
+	if (ret < 0 && ret != -ENXIO)
+		return ret;
+	if (ret > 0)
+		port->irq = ret;
 	else if (platp)
 		port->irq = platp->irq;
 
-- 
2.17.1


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

* [PATCH 02/10] serial: 8250_bcm7271: Use platform_get_irq() to get the interrupt
  2021-12-24 14:29 [PATCH 00/10] serial: Use platform_get_irq*() variants to fetch IRQ's Lad Prabhakar
  2021-12-24 14:29 ` [PATCH 01/10] serial: altera: Use platform_get_irq_optional() to get the interrupt Lad Prabhakar
@ 2021-12-24 14:29 ` Lad Prabhakar
  2021-12-24 22:10   ` Florian Fainelli
  2021-12-24 14:29 ` [PATCH 03/10] serial: 8250_bcm7271: Propagate error codes from brcmuart_probe() Lad Prabhakar
                   ` (7 subsequent siblings)
  9 siblings, 1 reply; 16+ messages in thread
From: Lad Prabhakar @ 2021-12-24 14:29 UTC (permalink / raw)
  To: linux-serial, Al Cooper, Greg Kroah-Hartman, Jiri Slaby
  Cc: Rob Herring, linux-kernel, Prabhakar, Lad Prabhakar,
	bcm-kernel-feedback-list

platform_get_resource(pdev, IORESOURCE_IRQ, ..) relies on static
allocation of IRQ resources in DT core code, this causes an issue
when using hierarchical interrupt domains using "interrupts" property
in the node as this bypasses the hierarchical setup and messes up the
irq chaining.

In preparation for removal of static setup of IRQ resource from DT core
code use platform_get_irq().

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
 drivers/tty/serial/8250/8250_bcm7271.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_bcm7271.c b/drivers/tty/serial/8250/8250_bcm7271.c
index 5163d60756b7..7ecfcc650d28 100644
--- a/drivers/tty/serial/8250/8250_bcm7271.c
+++ b/drivers/tty/serial/8250/8250_bcm7271.c
@@ -941,7 +941,7 @@ static int brcmuart_probe(struct platform_device *pdev)
 	struct brcmuart_priv *priv;
 	struct clk *baud_mux_clk;
 	struct uart_8250_port up;
-	struct resource *irq;
+	int irq;
 	void __iomem *membase = NULL;
 	resource_size_t mapbase = 0;
 	u32 clk_rate = 0;
@@ -952,11 +952,9 @@ static int brcmuart_probe(struct platform_device *pdev)
 		"uart", "dma_rx", "dma_tx", "dma_intr2", "dma_arb"
 	};
 
-	irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
-	if (!irq) {
-		dev_err(dev, "missing irq\n");
-		return -EINVAL;
-	}
+	irq = platform_get_irq(pdev, 0);
+	if (irq < 0)
+		return irq;
 	priv = devm_kzalloc(dev, sizeof(struct brcmuart_priv),
 			GFP_KERNEL);
 	if (!priv)
@@ -1044,7 +1042,7 @@ static int brcmuart_probe(struct platform_device *pdev)
 	up.port.dev = dev;
 	up.port.mapbase = mapbase;
 	up.port.membase = membase;
-	up.port.irq = irq->start;
+	up.port.irq = irq;
 	up.port.handle_irq = brcmuart_handle_irq;
 	up.port.regshift = 2;
 	up.port.iotype = of_device_is_big_endian(np) ?
-- 
2.17.1


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

* [PATCH 03/10] serial: 8250_bcm7271: Propagate error codes from brcmuart_probe()
  2021-12-24 14:29 [PATCH 00/10] serial: Use platform_get_irq*() variants to fetch IRQ's Lad Prabhakar
  2021-12-24 14:29 ` [PATCH 01/10] serial: altera: Use platform_get_irq_optional() to get the interrupt Lad Prabhakar
  2021-12-24 14:29 ` [PATCH 02/10] serial: 8250_bcm7271: Use platform_get_irq() " Lad Prabhakar
@ 2021-12-24 14:29 ` Lad Prabhakar
  2021-12-24 22:11   ` Florian Fainelli
       [not found]   ` <CAHp75VdC+JifneoYRS3yoXoAhio+TXQzca3pku7ug=A_ewWrsg@mail.gmail.com>
  2021-12-24 14:29 ` [PATCH 04/10] serial: meson: Use platform_get_irq() to get the interrupt Lad Prabhakar
                   ` (6 subsequent siblings)
  9 siblings, 2 replies; 16+ messages in thread
From: Lad Prabhakar @ 2021-12-24 14:29 UTC (permalink / raw)
  To: linux-serial, Al Cooper, Greg Kroah-Hartman, Jiri Slaby
  Cc: Rob Herring, linux-kernel, Prabhakar, Lad Prabhakar,
	bcm-kernel-feedback-list

In case of failures brcmuart_probe() always returned -ENODEV, this
isn't correct for example platform_get_irq_byname() may return
-EPROBE_DEFER to handle such cases propagate error codes in
brcmuart_probe() in case of failures.

Fixes: 41a469482de25 ("serial: 8250: Add new 8250-core based Broadcom STB driver")
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
 drivers/tty/serial/8250/8250_bcm7271.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_bcm7271.c b/drivers/tty/serial/8250/8250_bcm7271.c
index 7ecfcc650d28..cc60a7874e8b 100644
--- a/drivers/tty/serial/8250/8250_bcm7271.c
+++ b/drivers/tty/serial/8250/8250_bcm7271.c
@@ -1074,14 +1074,18 @@ static int brcmuart_probe(struct platform_device *pdev)
 		priv->rx_bufs = dma_alloc_coherent(dev,
 						   priv->rx_size,
 						   &priv->rx_addr, GFP_KERNEL);
-		if (!priv->rx_bufs)
+		if (!priv->rx_bufs) {
+			ret = -EINVAL;
 			goto err;
+		}
 		priv->tx_size = UART_XMIT_SIZE;
 		priv->tx_buf = dma_alloc_coherent(dev,
 						  priv->tx_size,
 						  &priv->tx_addr, GFP_KERNEL);
-		if (!priv->tx_buf)
+		if (!priv->tx_buf) {
+			ret = -EINVAL;
 			goto err;
+		}
 	}
 
 	ret = serial8250_register_8250_port(&up);
@@ -1095,6 +1099,7 @@ static int brcmuart_probe(struct platform_device *pdev)
 	if (priv->dma_enabled) {
 		dma_irq = platform_get_irq_byname(pdev,  "dma");
 		if (dma_irq < 0) {
+			ret = dma_irq;
 			dev_err(dev, "no IRQ resource info\n");
 			goto err1;
 		}
@@ -1114,7 +1119,7 @@ static int brcmuart_probe(struct platform_device *pdev)
 err:
 	brcmuart_free_bufs(dev, priv);
 	brcmuart_arbitration(priv, 0);
-	return -ENODEV;
+	return ret;
 }
 
 static int brcmuart_remove(struct platform_device *pdev)
-- 
2.17.1


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

* [PATCH 04/10] serial: meson: Use platform_get_irq() to get the interrupt
  2021-12-24 14:29 [PATCH 00/10] serial: Use platform_get_irq*() variants to fetch IRQ's Lad Prabhakar
                   ` (2 preceding siblings ...)
  2021-12-24 14:29 ` [PATCH 03/10] serial: 8250_bcm7271: Propagate error codes from brcmuart_probe() Lad Prabhakar
@ 2021-12-24 14:29 ` Lad Prabhakar
  2021-12-24 14:29 ` [PATCH 05/10] serial: pxa: " Lad Prabhakar
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 16+ messages in thread
From: Lad Prabhakar @ 2021-12-24 14:29 UTC (permalink / raw)
  To: linux-serial, Greg Kroah-Hartman, Jiri Slaby, Neil Armstrong,
	Kevin Hilman, Jerome Brunet, Martin Blumenstingl
  Cc: Rob Herring, linux-kernel, Prabhakar, Lad Prabhakar,
	linux-arm-kernel, linux-amlogic

platform_get_resource(pdev, IORESOURCE_IRQ, ..) relies on static
allocation of IRQ resources in DT core code, this causes an issue
when using hierarchical interrupt domains using "interrupts" property
in the node as this bypasses the hierarchical setup and messes up the
irq chaining.

In preparation for removal of static setup of IRQ resource from DT core
code use platform_get_irq().

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
 drivers/tty/serial/meson_uart.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/tty/serial/meson_uart.c b/drivers/tty/serial/meson_uart.c
index efee3935917f..4bc87f0c5868 100644
--- a/drivers/tty/serial/meson_uart.c
+++ b/drivers/tty/serial/meson_uart.c
@@ -713,10 +713,11 @@ static int meson_uart_probe_clocks(struct platform_device *pdev,
 
 static int meson_uart_probe(struct platform_device *pdev)
 {
-	struct resource *res_mem, *res_irq;
+	struct resource *res_mem;
 	struct uart_port *port;
 	u32 fifosize = 64; /* Default is 64, 128 for EE UART_0 */
 	int ret = 0;
+	int irq;
 
 	if (pdev->dev.of_node)
 		pdev->id = of_alias_get_id(pdev->dev.of_node, "serial");
@@ -739,9 +740,9 @@ static int meson_uart_probe(struct platform_device *pdev)
 	if (!res_mem)
 		return -ENODEV;
 
-	res_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
-	if (!res_irq)
-		return -ENODEV;
+	irq = platform_get_irq(pdev, 0);
+	if (irq < 0)
+		return irq;
 
 	of_property_read_u32(pdev->dev.of_node, "fifo-size", &fifosize);
 
@@ -766,7 +767,7 @@ static int meson_uart_probe(struct platform_device *pdev)
 	port->iotype = UPIO_MEM;
 	port->mapbase = res_mem->start;
 	port->mapsize = resource_size(res_mem);
-	port->irq = res_irq->start;
+	port->irq = irq;
 	port->flags = UPF_BOOT_AUTOCONF | UPF_LOW_LATENCY;
 	port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_MESON_CONSOLE);
 	port->dev = &pdev->dev;
-- 
2.17.1


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

* [PATCH 05/10] serial: pxa: Use platform_get_irq() to get the interrupt
  2021-12-24 14:29 [PATCH 00/10] serial: Use platform_get_irq*() variants to fetch IRQ's Lad Prabhakar
                   ` (3 preceding siblings ...)
  2021-12-24 14:29 ` [PATCH 04/10] serial: meson: Use platform_get_irq() to get the interrupt Lad Prabhakar
@ 2021-12-24 14:29 ` Lad Prabhakar
  2021-12-24 14:29 ` [PATCH 06/10] serial: altera_jtaguart: Use platform_get_irq_optional() " Lad Prabhakar
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 16+ messages in thread
From: Lad Prabhakar @ 2021-12-24 14:29 UTC (permalink / raw)
  To: linux-serial, Greg Kroah-Hartman, Jiri Slaby
  Cc: Rob Herring, linux-kernel, Prabhakar, Lad Prabhakar

platform_get_resource(pdev, IORESOURCE_IRQ, ..) relies on static
allocation of IRQ resources in DT core code, this causes an issue
when using hierarchical interrupt domains using "interrupts" property
in the node as this bypasses the hierarchical setup and messes up the
irq chaining.

In preparation for removal of static setup of IRQ resource from DT core
code use platform_get_irq().

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
 drivers/tty/serial/pxa.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/serial/pxa.c b/drivers/tty/serial/pxa.c
index 41319ef96fa6..30b099746a75 100644
--- a/drivers/tty/serial/pxa.c
+++ b/drivers/tty/serial/pxa.c
@@ -842,14 +842,18 @@ static int serial_pxa_probe_dt(struct platform_device *pdev,
 static int serial_pxa_probe(struct platform_device *dev)
 {
 	struct uart_pxa_port *sport;
-	struct resource *mmres, *irqres;
+	struct resource *mmres;
 	int ret;
+	int irq;
 
 	mmres = platform_get_resource(dev, IORESOURCE_MEM, 0);
-	irqres = platform_get_resource(dev, IORESOURCE_IRQ, 0);
-	if (!mmres || !irqres)
+	if (!mmres)
 		return -ENODEV;
 
+	irq = platform_get_irq(dev, 0);
+	if (irq < 0)
+		return irq;
+
 	sport = kzalloc(sizeof(struct uart_pxa_port), GFP_KERNEL);
 	if (!sport)
 		return -ENOMEM;
@@ -869,7 +873,7 @@ static int serial_pxa_probe(struct platform_device *dev)
 	sport->port.type = PORT_PXA;
 	sport->port.iotype = UPIO_MEM;
 	sport->port.mapbase = mmres->start;
-	sport->port.irq = irqres->start;
+	sport->port.irq = irq;
 	sport->port.fifosize = 64;
 	sport->port.ops = &serial_pxa_pops;
 	sport->port.dev = &dev->dev;
-- 
2.17.1


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

* [PATCH 06/10] serial: altera_jtaguart: Use platform_get_irq_optional() to get the interrupt
  2021-12-24 14:29 [PATCH 00/10] serial: Use platform_get_irq*() variants to fetch IRQ's Lad Prabhakar
                   ` (4 preceding siblings ...)
  2021-12-24 14:29 ` [PATCH 05/10] serial: pxa: " Lad Prabhakar
@ 2021-12-24 14:29 ` Lad Prabhakar
  2021-12-24 14:29 ` [PATCH 07/10] serial: vt8500: Use platform_get_irq() " Lad Prabhakar
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 16+ messages in thread
From: Lad Prabhakar @ 2021-12-24 14:29 UTC (permalink / raw)
  To: linux-serial, Tobias Klauser, Greg Kroah-Hartman, Jiri Slaby
  Cc: Rob Herring, linux-kernel, Prabhakar, Lad Prabhakar

platform_get_resource(pdev, IORESOURCE_IRQ, ..) relies on static
allocation of IRQ resources in DT core code, this causes an issue
when using hierarchical interrupt domains using "interrupts" property
in the node as this bypasses the hierarchical setup and messes up the
irq chaining.

In preparation for removal of static setup of IRQ resource from DT core
code use platform_get_irq_optional().

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
 drivers/tty/serial/altera_jtaguart.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/serial/altera_jtaguart.c b/drivers/tty/serial/altera_jtaguart.c
index 23c4e0e79694..37bffe406b18 100644
--- a/drivers/tty/serial/altera_jtaguart.c
+++ b/drivers/tty/serial/altera_jtaguart.c
@@ -418,8 +418,9 @@ static int altera_jtaguart_probe(struct platform_device *pdev)
 	struct altera_jtaguart_platform_uart *platp =
 			dev_get_platdata(&pdev->dev);
 	struct uart_port *port;
-	struct resource *res_irq, *res_mem;
+	struct resource *res_mem;
 	int i = pdev->id;
+	int irq;
 
 	/* -1 emphasizes that the platform must have one port, no .N suffix */
 	if (i == -1)
@@ -438,9 +439,11 @@ static int altera_jtaguart_probe(struct platform_device *pdev)
 	else
 		return -ENODEV;
 
-	res_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
-	if (res_irq)
-		port->irq = res_irq->start;
+	irq = platform_get_irq_optional(pdev, 0);
+	if (irq < 0 && irq != -ENXIO)
+		return irq;
+	if (irq > 0)
+		port->irq = irq;
 	else if (platp)
 		port->irq = platp->irq;
 	else
-- 
2.17.1


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

* [PATCH 07/10] serial: vt8500: Use platform_get_irq() to get the interrupt
  2021-12-24 14:29 [PATCH 00/10] serial: Use platform_get_irq*() variants to fetch IRQ's Lad Prabhakar
                   ` (5 preceding siblings ...)
  2021-12-24 14:29 ` [PATCH 06/10] serial: altera_jtaguart: Use platform_get_irq_optional() " Lad Prabhakar
@ 2021-12-24 14:29 ` Lad Prabhakar
  2021-12-24 14:29 ` [PATCH 08/10] serial: ar933x: " Lad Prabhakar
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 16+ messages in thread
From: Lad Prabhakar @ 2021-12-24 14:29 UTC (permalink / raw)
  To: linux-serial, Greg Kroah-Hartman, Jiri Slaby
  Cc: Rob Herring, linux-kernel, Prabhakar, Lad Prabhakar, linux-arm-kernel

platform_get_resource(pdev, IORESOURCE_IRQ, ..) relies on static
allocation of IRQ resources in DT core code, this causes an issue
when using hierarchical interrupt domains using "interrupts" property
in the node as this bypasses the hierarchical setup and messes up the
irq chaining.

In preparation for removal of static setup of IRQ resource from DT core
code use platform_get_irq().

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
 drivers/tty/serial/vt8500_serial.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/serial/vt8500_serial.c b/drivers/tty/serial/vt8500_serial.c
index e15b2bf69904..9adfe3dc970f 100644
--- a/drivers/tty/serial/vt8500_serial.c
+++ b/drivers/tty/serial/vt8500_serial.c
@@ -621,21 +621,25 @@ static const struct of_device_id wmt_dt_ids[] = {
 static int vt8500_serial_probe(struct platform_device *pdev)
 {
 	struct vt8500_port *vt8500_port;
-	struct resource *mmres, *irqres;
+	struct resource *mmres;
 	struct device_node *np = pdev->dev.of_node;
 	const unsigned int *flags;
 	int ret;
 	int port;
+	int irq;
 
 	flags = of_device_get_match_data(&pdev->dev);
 	if (!flags)
 		return -EINVAL;
 
 	mmres = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	irqres = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
-	if (!mmres || !irqres)
+	if (!mmres)
 		return -ENODEV;
 
+	irq = platform_get_irq(pdev, 0);
+	if (irq < 0)
+		return irq;
+
 	if (np) {
 		port = of_alias_get_id(np, "serial");
 		if (port >= VT8500_MAX_PORTS)
@@ -688,7 +692,7 @@ static int vt8500_serial_probe(struct platform_device *pdev)
 	vt8500_port->uart.type = PORT_VT8500;
 	vt8500_port->uart.iotype = UPIO_MEM;
 	vt8500_port->uart.mapbase = mmres->start;
-	vt8500_port->uart.irq = irqres->start;
+	vt8500_port->uart.irq = irq;
 	vt8500_port->uart.fifosize = 16;
 	vt8500_port->uart.ops = &vt8500_uart_pops;
 	vt8500_port->uart.line = port;
-- 
2.17.1


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

* [PATCH 08/10] serial: ar933x: Use platform_get_irq() to get the interrupt
  2021-12-24 14:29 [PATCH 00/10] serial: Use platform_get_irq*() variants to fetch IRQ's Lad Prabhakar
                   ` (6 preceding siblings ...)
  2021-12-24 14:29 ` [PATCH 07/10] serial: vt8500: Use platform_get_irq() " Lad Prabhakar
@ 2021-12-24 14:29 ` Lad Prabhakar
  2021-12-24 14:29 ` [PATCH 09/10] serial: bcm63xx: " Lad Prabhakar
  2021-12-24 14:29 ` [PATCH 10/10] serial: pmac_zilog: " Lad Prabhakar
  9 siblings, 0 replies; 16+ messages in thread
From: Lad Prabhakar @ 2021-12-24 14:29 UTC (permalink / raw)
  To: linux-serial, Greg Kroah-Hartman, Jiri Slaby
  Cc: Rob Herring, linux-kernel, Prabhakar, Lad Prabhakar

platform_get_resource(pdev, IORESOURCE_IRQ, ..) relies on static
allocation of IRQ resources in DT core code, this causes an issue
when using hierarchical interrupt domains using "interrupts" property
in the node as this bypasses the hierarchical setup and messes up the
irq chaining.

In preparation for removal of static setup of IRQ resource from DT core
code use platform_get_irq().

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
 drivers/tty/serial/ar933x_uart.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/tty/serial/ar933x_uart.c b/drivers/tty/serial/ar933x_uart.c
index 4379ca4842ae..8cabe50c4a33 100644
--- a/drivers/tty/serial/ar933x_uart.c
+++ b/drivers/tty/serial/ar933x_uart.c
@@ -707,11 +707,11 @@ static int ar933x_uart_probe(struct platform_device *pdev)
 	struct ar933x_uart_port *up;
 	struct uart_port *port;
 	struct resource *mem_res;
-	struct resource *irq_res;
 	struct device_node *np;
 	unsigned int baud;
 	int id;
 	int ret;
+	int irq;
 
 	np = pdev->dev.of_node;
 	if (IS_ENABLED(CONFIG_OF) && np) {
@@ -730,11 +730,9 @@ static int ar933x_uart_probe(struct platform_device *pdev)
 	if (id >= CONFIG_SERIAL_AR933X_NR_UARTS)
 		return -EINVAL;
 
-	irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
-	if (!irq_res) {
-		dev_err(&pdev->dev, "no IRQ resource\n");
-		return -EINVAL;
-	}
+	irq = platform_get_irq(pdev, 0);
+	if (irq < 0)
+		return irq;
 
 	up = devm_kzalloc(&pdev->dev, sizeof(struct ar933x_uart_port),
 			  GFP_KERNEL);
@@ -766,7 +764,7 @@ static int ar933x_uart_probe(struct platform_device *pdev)
 
 	port->mapbase = mem_res->start;
 	port->line = id;
-	port->irq = irq_res->start;
+	port->irq = irq;
 	port->dev = &pdev->dev;
 	port->type = PORT_AR933X;
 	port->iotype = UPIO_MEM32;
-- 
2.17.1


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

* [PATCH 09/10] serial: bcm63xx: Use platform_get_irq() to get the interrupt
  2021-12-24 14:29 [PATCH 00/10] serial: Use platform_get_irq*() variants to fetch IRQ's Lad Prabhakar
                   ` (7 preceding siblings ...)
  2021-12-24 14:29 ` [PATCH 08/10] serial: ar933x: " Lad Prabhakar
@ 2021-12-24 14:29 ` Lad Prabhakar
  2021-12-24 17:05   ` Florian Fainelli
  2021-12-24 14:29 ` [PATCH 10/10] serial: pmac_zilog: " Lad Prabhakar
  9 siblings, 1 reply; 16+ messages in thread
From: Lad Prabhakar @ 2021-12-24 14:29 UTC (permalink / raw)
  To: linux-serial, Greg Kroah-Hartman, Jiri Slaby, Florian Fainelli,
	bcm-kernel-feedback-list
  Cc: Rob Herring, linux-kernel, Prabhakar, Lad Prabhakar, linux-arm-kernel

platform_get_resource(pdev, IORESOURCE_IRQ, ..) relies on static
allocation of IRQ resources in DT core code, this causes an issue
when using hierarchical interrupt domains using "interrupts" property
in the node as this bypasses the hierarchical setup and messes up the
irq chaining.

In preparation for removal of static setup of IRQ resource from DT core
code use platform_get_irq().

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
 drivers/tty/serial/bcm63xx_uart.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/tty/serial/bcm63xx_uart.c b/drivers/tty/serial/bcm63xx_uart.c
index 5fb0e84f7fd1..6471a54b616b 100644
--- a/drivers/tty/serial/bcm63xx_uart.c
+++ b/drivers/tty/serial/bcm63xx_uart.c
@@ -804,7 +804,7 @@ static struct uart_driver bcm_uart_driver = {
  */
 static int bcm_uart_probe(struct platform_device *pdev)
 {
-	struct resource *res_mem, *res_irq;
+	struct resource *res_mem;
 	struct uart_port *port;
 	struct clk *clk;
 	int ret;
@@ -833,9 +833,10 @@ static int bcm_uart_probe(struct platform_device *pdev)
 	if (IS_ERR(port->membase))
 		return PTR_ERR(port->membase);
 
-	res_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
-	if (!res_irq)
-		return -ENODEV;
+	ret = platform_get_irq(pdev, 0);
+	if (ret < 0)
+		return ret;
+	port->irq = ret;
 
 	clk = clk_get(&pdev->dev, "refclk");
 	if (IS_ERR(clk) && pdev->dev.of_node)
@@ -845,7 +846,6 @@ static int bcm_uart_probe(struct platform_device *pdev)
 		return -ENODEV;
 
 	port->iotype = UPIO_MEM;
-	port->irq = res_irq->start;
 	port->ops = &bcm_uart_ops;
 	port->flags = UPF_BOOT_AUTOCONF;
 	port->dev = &pdev->dev;
-- 
2.17.1


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

* [PATCH 10/10] serial: pmac_zilog: Use platform_get_irq() to get the interrupt
  2021-12-24 14:29 [PATCH 00/10] serial: Use platform_get_irq*() variants to fetch IRQ's Lad Prabhakar
                   ` (8 preceding siblings ...)
  2021-12-24 14:29 ` [PATCH 09/10] serial: bcm63xx: " Lad Prabhakar
@ 2021-12-24 14:29 ` Lad Prabhakar
  9 siblings, 0 replies; 16+ messages in thread
From: Lad Prabhakar @ 2021-12-24 14:29 UTC (permalink / raw)
  To: linux-serial, Greg Kroah-Hartman, Jiri Slaby, Michael Ellerman,
	Benjamin Herrenschmidt, Paul Mackerras
  Cc: Rob Herring, linux-kernel, Prabhakar, Lad Prabhakar, linuxppc-dev

platform_get_resource(pdev, IORESOURCE_IRQ, ..) relies on static
allocation of IRQ resources in DT core code, this causes an issue
when using hierarchical interrupt domains using "interrupts" property
in the node as this bypasses the hierarchical setup and messes up the
irq chaining.

In preparation for removal of static setup of IRQ resource from DT core
code use platform_get_irq().

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
 drivers/tty/serial/pmac_zilog.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/serial/pmac_zilog.c b/drivers/tty/serial/pmac_zilog.c
index 12ce150b0ad4..5359236b32d6 100644
--- a/drivers/tty/serial/pmac_zilog.c
+++ b/drivers/tty/serial/pmac_zilog.c
@@ -1702,17 +1702,21 @@ extern struct platform_device scc_a_pdev, scc_b_pdev;
 
 static int __init pmz_init_port(struct uart_pmac_port *uap)
 {
-	struct resource *r_ports, *r_irq;
+	struct resource *r_ports;
+	int irq;
 
 	r_ports = platform_get_resource(uap->pdev, IORESOURCE_MEM, 0);
-	r_irq = platform_get_resource(uap->pdev, IORESOURCE_IRQ, 0);
-	if (!r_ports || !r_irq)
+	if (!r_ports)
 		return -ENODEV;
 
+	irq = platform_get_irq(uap->pdev, 0);
+	if (irq < 0)
+		return irq;
+
 	uap->port.mapbase  = r_ports->start;
 	uap->port.membase  = (unsigned char __iomem *) r_ports->start;
 	uap->port.iotype   = UPIO_MEM;
-	uap->port.irq      = r_irq->start;
+	uap->port.irq      = irq;
 	uap->port.uartclk  = ZS_CLOCK;
 	uap->port.fifosize = 1;
 	uap->port.ops      = &pmz_pops;
-- 
2.17.1


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

* Re: [PATCH 09/10] serial: bcm63xx: Use platform_get_irq() to get the interrupt
  2021-12-24 14:29 ` [PATCH 09/10] serial: bcm63xx: " Lad Prabhakar
@ 2021-12-24 17:05   ` Florian Fainelli
  0 siblings, 0 replies; 16+ messages in thread
From: Florian Fainelli @ 2021-12-24 17:05 UTC (permalink / raw)
  To: Lad Prabhakar, linux-serial, Greg Kroah-Hartman, Jiri Slaby,
	bcm-kernel-feedback-list
  Cc: Rob Herring, linux-kernel, Prabhakar, linux-arm-kernel



On 12/24/2021 06:29, Lad Prabhakar wrote:
> platform_get_resource(pdev, IORESOURCE_IRQ, ..) relies on static
> allocation of IRQ resources in DT core code, this causes an issue
> when using hierarchical interrupt domains using "interrupts" property
> in the node as this bypasses the hierarchical setup and messes up the
> irq chaining.
> 
> In preparation for removal of static setup of IRQ resource from DT core
> code use platform_get_irq().
> 
> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>

Acked-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

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

* Re: [PATCH 02/10] serial: 8250_bcm7271: Use platform_get_irq() to get the interrupt
  2021-12-24 14:29 ` [PATCH 02/10] serial: 8250_bcm7271: Use platform_get_irq() " Lad Prabhakar
@ 2021-12-24 22:10   ` Florian Fainelli
  0 siblings, 0 replies; 16+ messages in thread
From: Florian Fainelli @ 2021-12-24 22:10 UTC (permalink / raw)
  To: Lad Prabhakar, linux-serial, Al Cooper, Greg Kroah-Hartman, Jiri Slaby
  Cc: Rob Herring, linux-kernel, Prabhakar, bcm-kernel-feedback-list



On 12/24/2021 6:29 AM, Lad Prabhakar wrote:
> platform_get_resource(pdev, IORESOURCE_IRQ, ..) relies on static
> allocation of IRQ resources in DT core code, this causes an issue
> when using hierarchical interrupt domains using "interrupts" property
> in the node as this bypasses the hierarchical setup and messes up the
> irq chaining.
> 
> In preparation for removal of static setup of IRQ resource from DT core
> code use platform_get_irq().
> 
> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>

Acked-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

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

* Re: [PATCH 03/10] serial: 8250_bcm7271: Propagate error codes from brcmuart_probe()
  2021-12-24 14:29 ` [PATCH 03/10] serial: 8250_bcm7271: Propagate error codes from brcmuart_probe() Lad Prabhakar
@ 2021-12-24 22:11   ` Florian Fainelli
       [not found]   ` <CAHp75VdC+JifneoYRS3yoXoAhio+TXQzca3pku7ug=A_ewWrsg@mail.gmail.com>
  1 sibling, 0 replies; 16+ messages in thread
From: Florian Fainelli @ 2021-12-24 22:11 UTC (permalink / raw)
  To: Lad Prabhakar, linux-serial, Al Cooper, Greg Kroah-Hartman, Jiri Slaby
  Cc: Rob Herring, linux-kernel, Prabhakar, bcm-kernel-feedback-list



On 12/24/2021 6:29 AM, Lad Prabhakar wrote:
> In case of failures brcmuart_probe() always returned -ENODEV, this
> isn't correct for example platform_get_irq_byname() may return
> -EPROBE_DEFER to handle such cases propagate error codes in
> brcmuart_probe() in case of failures.
> 
> Fixes: 41a469482de25 ("serial: 8250: Add new 8250-core based Broadcom STB driver")
> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>

Acked-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

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

* Re: [PATCH 03/10] serial: 8250_bcm7271: Propagate error codes from brcmuart_probe()
       [not found]   ` <CAHp75VdC+JifneoYRS3yoXoAhio+TXQzca3pku7ug=A_ewWrsg@mail.gmail.com>
@ 2021-12-25 12:20     ` Lad, Prabhakar
  2021-12-30 12:27       ` Greg Kroah-Hartman
  0 siblings, 1 reply; 16+ messages in thread
From: Lad, Prabhakar @ 2021-12-25 12:20 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Lad Prabhakar, linux-serial, Al Cooper, Greg Kroah-Hartman,
	Jiri Slaby, Rob Herring, linux-kernel, bcm-kernel-feedback-list

Hi Andy,

Thank you for the review.

On Sat, Dec 25, 2021 at 11:20 AM Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
>
>
>
> On Friday, December 24, 2021, Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> wrote:
>>
>> In case of failures brcmuart_probe() always returned -ENODEV, this
>> isn't correct for example platform_get_irq_byname() may return
>> -EPROBE_DEFER to handle such cases propagate error codes in
>> brcmuart_probe() in case of failures.
>>
>> Fixes: 41a469482de25 ("serial: 8250: Add new 8250-core based Broadcom STB driver")
>> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
>> ---
>>  drivers/tty/serial/8250/8250_bcm7271.c | 11 ++++++++---
>>  1 file changed, 8 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/tty/serial/8250/8250_bcm7271.c b/drivers/tty/serial/8250/8250_bcm7271.c
>> index 7ecfcc650d28..cc60a7874e8b 100644
>> --- a/drivers/tty/serial/8250/8250_bcm7271.c
>> +++ b/drivers/tty/serial/8250/8250_bcm7271.c
>> @@ -1074,14 +1074,18 @@ static int brcmuart_probe(struct platform_device *pdev)
>>                 priv->rx_bufs = dma_alloc_coherent(dev,
>>                                                    priv->rx_size,
>>                                                    &priv->rx_addr, GFP_KERNEL);
>> -               if (!priv->rx_bufs)
>> +               if (!priv->rx_bufs) {
>> +                       ret = -EINVAL;
>
>
>
> For memory allocation we usually return -ENOMEM.
>
Agreed, will fix that.

Cheers,
Prabhakar
>>
>>                         goto err;
>> +               }
>>                 priv->tx_size = UART_XMIT_SIZE;
>>                 priv->tx_buf = dma_alloc_coherent(dev,
>>                                                   priv->tx_size,
>>                                                   &priv->tx_addr, GFP_KERNEL);
>> -               if (!priv->tx_buf)
>> +               if (!priv->tx_buf) {
>> +                       ret = -EINVAL;
>>                         goto err;
>> +               }
>>         }
>>
>>         ret = serial8250_register_8250_port(&up);
>> @@ -1095,6 +1099,7 @@ static int brcmuart_probe(struct platform_device *pdev)
>>         if (priv->dma_enabled) {
>>                 dma_irq = platform_get_irq_byname(pdev,  "dma");
>>                 if (dma_irq < 0) {
>> +                       ret = dma_irq;
>>                         dev_err(dev, "no IRQ resource info\n");
>>                         goto err1;
>>                 }
>> @@ -1114,7 +1119,7 @@ static int brcmuart_probe(struct platform_device *pdev)
>>  err:
>>         brcmuart_free_bufs(dev, priv);
>>         brcmuart_arbitration(priv, 0);
>> -       return -ENODEV;
>> +       return ret;
>>  }
>>
>>  static int brcmuart_remove(struct platform_device *pdev)
>> --
>> 2.17.1
>>
>
>
> --
> With Best Regards,
> Andy Shevchenko
>
>

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

* Re: [PATCH 03/10] serial: 8250_bcm7271: Propagate error codes from brcmuart_probe()
  2021-12-25 12:20     ` Lad, Prabhakar
@ 2021-12-30 12:27       ` Greg Kroah-Hartman
  0 siblings, 0 replies; 16+ messages in thread
From: Greg Kroah-Hartman @ 2021-12-30 12:27 UTC (permalink / raw)
  To: Lad, Prabhakar
  Cc: Andy Shevchenko, Lad Prabhakar, linux-serial, Al Cooper,
	Jiri Slaby, Rob Herring, linux-kernel, bcm-kernel-feedback-list

On Sat, Dec 25, 2021 at 12:20:02PM +0000, Lad, Prabhakar wrote:
> Hi Andy,
> 
> Thank you for the review.
> 
> On Sat, Dec 25, 2021 at 11:20 AM Andy Shevchenko
> <andy.shevchenko@gmail.com> wrote:
> >
> >
> >
> > On Friday, December 24, 2021, Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> wrote:
> >>
> >> In case of failures brcmuart_probe() always returned -ENODEV, this
> >> isn't correct for example platform_get_irq_byname() may return
> >> -EPROBE_DEFER to handle such cases propagate error codes in
> >> brcmuart_probe() in case of failures.
> >>
> >> Fixes: 41a469482de25 ("serial: 8250: Add new 8250-core based Broadcom STB driver")
> >> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> >> ---
> >>  drivers/tty/serial/8250/8250_bcm7271.c | 11 ++++++++---
> >>  1 file changed, 8 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/drivers/tty/serial/8250/8250_bcm7271.c b/drivers/tty/serial/8250/8250_bcm7271.c
> >> index 7ecfcc650d28..cc60a7874e8b 100644
> >> --- a/drivers/tty/serial/8250/8250_bcm7271.c
> >> +++ b/drivers/tty/serial/8250/8250_bcm7271.c
> >> @@ -1074,14 +1074,18 @@ static int brcmuart_probe(struct platform_device *pdev)
> >>                 priv->rx_bufs = dma_alloc_coherent(dev,
> >>                                                    priv->rx_size,
> >>                                                    &priv->rx_addr, GFP_KERNEL);
> >> -               if (!priv->rx_bufs)
> >> +               if (!priv->rx_bufs) {
> >> +                       ret = -EINVAL;
> >
> >
> >
> > For memory allocation we usually return -ENOMEM.
> >
> Agreed, will fix that.

Just send a follow-on patch for that, thanks.

greg k-h

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

end of thread, other threads:[~2021-12-30 12:27 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-24 14:29 [PATCH 00/10] serial: Use platform_get_irq*() variants to fetch IRQ's Lad Prabhakar
2021-12-24 14:29 ` [PATCH 01/10] serial: altera: Use platform_get_irq_optional() to get the interrupt Lad Prabhakar
2021-12-24 14:29 ` [PATCH 02/10] serial: 8250_bcm7271: Use platform_get_irq() " Lad Prabhakar
2021-12-24 22:10   ` Florian Fainelli
2021-12-24 14:29 ` [PATCH 03/10] serial: 8250_bcm7271: Propagate error codes from brcmuart_probe() Lad Prabhakar
2021-12-24 22:11   ` Florian Fainelli
     [not found]   ` <CAHp75VdC+JifneoYRS3yoXoAhio+TXQzca3pku7ug=A_ewWrsg@mail.gmail.com>
2021-12-25 12:20     ` Lad, Prabhakar
2021-12-30 12:27       ` Greg Kroah-Hartman
2021-12-24 14:29 ` [PATCH 04/10] serial: meson: Use platform_get_irq() to get the interrupt Lad Prabhakar
2021-12-24 14:29 ` [PATCH 05/10] serial: pxa: " Lad Prabhakar
2021-12-24 14:29 ` [PATCH 06/10] serial: altera_jtaguart: Use platform_get_irq_optional() " Lad Prabhakar
2021-12-24 14:29 ` [PATCH 07/10] serial: vt8500: Use platform_get_irq() " Lad Prabhakar
2021-12-24 14:29 ` [PATCH 08/10] serial: ar933x: " Lad Prabhakar
2021-12-24 14:29 ` [PATCH 09/10] serial: bcm63xx: " Lad Prabhakar
2021-12-24 17:05   ` Florian Fainelli
2021-12-24 14:29 ` [PATCH 10/10] serial: pmac_zilog: " Lad Prabhakar

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