diff mbox series

[1/3] dmaengine: nbpfaxi: Use platform_get_irq_optional() to get the interrupt

Message ID 20211222161534.1263-2-prabhakar.mahadev-lad.rj@bp.renesas.com (mailing list archive)
State New, archived
Headers show
Series dmaengine: Use platform_get_irq*() variants to fetch IRQ's | expand

Commit Message

Prabhakar Dec. 22, 2021, 4:15 p.m. UTC
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().

There are no non-DT users for this driver so interrupt range
(irq_res->start-irq_res->end) is no longer required and with DT we will
be sure it will be a single IRQ resource for each index.

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
 drivers/dma/nbpfaxi.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

Comments

Andy Shevchenko Dec. 25, 2021, 5:46 p.m. UTC | #1
On Fri, Dec 24, 2021 at 3:14 PM Lad Prabhakar
<prabhakar.mahadev-lad.rj@bp.renesas.com> 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_optional().
>
> There are no non-DT users for this driver so interrupt range
> (irq_res->start-irq_res->end) is no longer required and with DT we will
> be sure it will be a single IRQ resource for each index.

>         for (i = 0; irqs < ARRAY_SIZE(irqbuf); i++) {
> -               irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, i);
> -               if (!irq_res)
> +               irq = platform_get_irq_optional(pdev, i);
> +               if (irq == -ENXIO)
>                         break;
> -
> -               for (irq = irq_res->start; irq <= irq_res->end;
> -                    irq++, irqs++)
> -                       irqbuf[irqs] = irq;
> +               if (irq < 0)
> +                       return irq;
> +               irqbuf[irqs++] = irq;
>         }

Same comment as per other patch(es), i.e. consider 0 as no IRQ.
Lad, Prabhakar Dec. 25, 2021, 11:50 p.m. UTC | #2
Hi Andy,

Thank you for the review.

On Sat, Dec 25, 2021 at 5:47 PM Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
>
> On Fri, Dec 24, 2021 at 3:14 PM Lad Prabhakar
> <prabhakar.mahadev-lad.rj@bp.renesas.com> 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_optional().
> >
> > There are no non-DT users for this driver so interrupt range
> > (irq_res->start-irq_res->end) is no longer required and with DT we will
> > be sure it will be a single IRQ resource for each index.
>
> >         for (i = 0; irqs < ARRAY_SIZE(irqbuf); i++) {
> > -               irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, i);
> > -               if (!irq_res)
> > +               irq = platform_get_irq_optional(pdev, i);
> > +               if (irq == -ENXIO)
> >                         break;
> > -
> > -               for (irq = irq_res->start; irq <= irq_res->end;
> > -                    irq++, irqs++)
> > -                       irqbuf[irqs] = irq;
> > +               if (irq < 0)
> > +                       return irq;
> > +               irqbuf[irqs++] = irq;
> >         }
>
> Same comment as per other patch(es), i.e. consider 0 as no IRQ.
>
Will do.

Cheers,
Prabhakar
diff mbox series

Patch

diff --git a/drivers/dma/nbpfaxi.c b/drivers/dma/nbpfaxi.c
index 9c52c57919c6..135c12b0a2df 100644
--- a/drivers/dma/nbpfaxi.c
+++ b/drivers/dma/nbpfaxi.c
@@ -1294,7 +1294,7 @@  static int nbpf_probe(struct platform_device *pdev)
 	struct device_node *np = dev->of_node;
 	struct nbpf_device *nbpf;
 	struct dma_device *dma_dev;
-	struct resource *iomem, *irq_res;
+	struct resource *iomem;
 	const struct nbpf_config *cfg;
 	int num_channels;
 	int ret, irq, eirq, i;
@@ -1335,13 +1335,12 @@  static int nbpf_probe(struct platform_device *pdev)
 	nbpf->config = cfg;
 
 	for (i = 0; irqs < ARRAY_SIZE(irqbuf); i++) {
-		irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, i);
-		if (!irq_res)
+		irq = platform_get_irq_optional(pdev, i);
+		if (irq == -ENXIO)
 			break;
-
-		for (irq = irq_res->start; irq <= irq_res->end;
-		     irq++, irqs++)
-			irqbuf[irqs] = irq;
+		if (irq < 0)
+			return irq;
+		irqbuf[irqs++] = irq;
 	}
 
 	/*