Re: [PATCHv2 1/4] memory: fsl_ifc: Fix optional NAND IRQ handling and migrate to platform IRQ API

From: Krzysztof Kozlowski

Date: Tue Sep 01 2026 - 11:49:20 EST


On 21/07/2026 22:24, Rosen Penev wrote:
> Switch from irq_of_parse_and_map() to platform_get_irq() for the main
> controller IRQ, and use platform_get_irq_optional() for the NAND IRQ
> which is optional. Guard free_irq() calls on the NAND IRQ with a
> nand_irq > 0 check to avoid passing invalid IRQ numbers on platforms
> without a dedicated NAND interrupt line.
>
> Get IRQs first as they can return a probe defferal error. Helps avoid
> doing actual work in such a case.
>
> Assisted-by: opencode:big-pickle
> Signed-off-by: Rosen Penev <rosenp@xxxxxxxxx>
> ---
> drivers/memory/fsl_ifc.c | 43 ++++++++++++++++++++--------------------
> 1 file changed, 21 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/memory/fsl_ifc.c b/drivers/memory/fsl_ifc.c
> index e89e0c6cc4bc..dce94d8b05b9 100644
> --- a/drivers/memory/fsl_ifc.c
> +++ b/drivers/memory/fsl_ifc.c
> @@ -89,12 +89,10 @@ static void fsl_ifc_ctrl_remove(struct platform_device *dev)
> struct fsl_ifc_ctrl *ctrl = dev_get_drvdata(&dev->dev);
>
> of_platform_depopulate(&dev->dev);
> - free_irq(ctrl->nand_irq, ctrl);
> + if (ctrl->nand_irq > 0)

0 is a valid IRQ for Linux, I think.

> + free_irq(ctrl->nand_irq, ctrl);
> free_irq(ctrl->irq, ctrl);
>
> - irq_dispose_mapping(ctrl->nand_irq);
> - irq_dispose_mapping(ctrl->irq);
> -
> iounmap(ctrl->gregs);
>
> dev_set_drvdata(&dev->dev, NULL);
> @@ -204,9 +202,21 @@ static int fsl_ifc_ctrl_probe(struct platform_device *dev)
> int ret = 0;
> int version, banks;
> void __iomem *addr;
> + int nand_irq;
> + int irq;

Why do you need the intermediate variables?

>
> dev_info(&dev->dev, "Freescale Integrated Flash Controller\n");
>
> + /* get the Controller level irq */
> + irq = platform_get_irq(dev, 0);
> + if (irq < 0)

... as also shown here.

> + return irq;
> +
> + /* get the nand machine irq */
> + nand_irq = platform_get_irq_optional(dev, 1);
> + if (nand_irq == -EPROBE_DEFER)
> + return nand_irq;
> +
> fsl_ifc_ctrl_dev = devm_kzalloc(&dev->dev, sizeof(*fsl_ifc_ctrl_dev),
> GFP_KERNEL);
> if (!fsl_ifc_ctrl_dev)
> @@ -246,23 +256,13 @@ static int fsl_ifc_ctrl_probe(struct platform_device *dev)
> addr += PGOFFSET_4K;
> fsl_ifc_ctrl_dev->rregs = addr;
>
> - /* get the Controller level irq */
> - fsl_ifc_ctrl_dev->irq = irq_of_parse_and_map(dev->dev.of_node, 0);
> - if (fsl_ifc_ctrl_dev->irq == 0) {
> - dev_err(&dev->dev, "failed to get irq resource for IFC\n");
> - ret = -ENODEV;
> - goto err;
> - }
> -
> - /* get the nand machine irq */
> - fsl_ifc_ctrl_dev->nand_irq =
> - irq_of_parse_and_map(dev->dev.of_node, 1);
> + fsl_ifc_ctrl_dev->irq = irq;
>
> fsl_ifc_ctrl_dev->dev = &dev->dev;
>
> ret = fsl_ifc_ctrl_init(fsl_ifc_ctrl_dev);
> if (ret < 0)
> - goto err_unmap_nandirq;
> + goto err;
>
> init_waitqueue_head(&fsl_ifc_ctrl_dev->nand_wait);
>
> @@ -271,10 +271,11 @@ static int fsl_ifc_ctrl_probe(struct platform_device *dev)
> if (ret != 0) {
> dev_err(&dev->dev, "failed to install irq (%d)\n",
> fsl_ifc_ctrl_dev->irq);
> - goto err_unmap_nandirq;
> + goto err;
> }
>
> - if (fsl_ifc_ctrl_dev->nand_irq) {
> + fsl_ifc_ctrl_dev->nand_irq = nand_irq;
> + if (fsl_ifc_ctrl_dev->nand_irq > 0) {

...but not here.

> ret = request_irq(fsl_ifc_ctrl_dev->nand_irq, fsl_ifc_nand_irq,
> 0, "fsl-ifc-nand", fsl_ifc_ctrl_dev);
> if (ret != 0) {
> @@ -292,12 +293,10 @@ static int fsl_ifc_ctrl_probe(struct platform_device *dev)
> return 0;
>
> err_free_nandirq:
> - free_irq(fsl_ifc_ctrl_dev->nand_irq, fsl_ifc_ctrl_dev);
> + if (fsl_ifc_ctrl_dev->nand_irq > 0)
> + free_irq(fsl_ifc_ctrl_dev->nand_irq, fsl_ifc_ctrl_dev);
> err_free_irq:
> free_irq(fsl_ifc_ctrl_dev->irq, fsl_ifc_ctrl_dev);
> -err_unmap_nandirq:
> - irq_dispose_mapping(fsl_ifc_ctrl_dev->nand_irq);
> - irq_dispose_mapping(fsl_ifc_ctrl_dev->irq);
> err:
> iounmap(fsl_ifc_ctrl_dev->gregs);
> return ret;


Best regards,
Krzysztof