Re: [PATCH v3] media: davinci: vpif: Use platform_get_irq_optional() to get the interrupt

From: Andy Shevchenko
Date: Wed Jan 12 2022 - 06:34:29 EST


On Tue, Jan 11, 2022 at 9:40 PM Lad Prabhakar
<prabhakar.mahadev-lad.rj@xxxxxxxxxxxxxx> 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().
>
> While at it, propagate error code in case devm_request_irq() fails
> instead of returning -EINVAL.

...

> + while (1) {

The infinite loop use is discouraged.

> + int irq;
> +
> + err = platform_get_irq_optional(pdev, res_idx);
> + if (err < 0 && err != -ENXIO)
> + goto vpif_unregister;
> + if (err > 0)
> + irq = err;
> + else
> + break;
> +
> + err = devm_request_irq(&pdev->dev, irq, vpif_channel_isr,
> + IRQF_SHARED, VPIF_DRIVER_NAME,
> + (void *)(&vpif_obj.dev[res_idx]->channel_id));
> + if (err)
> goto vpif_unregister;
> - }
> res_idx++;
> }

Slightly better

do {
...
} while (++res_idx);

...

> + while (1) {

Ditto.

--
With Best Regards,
Andy Shevchenko