Re: [PATCH 4/4] spi: nxp-fspi: disable runtime PM on probe failures
From: Frank Li
Date: Sat Jun 20 2026 - 10:10:10 EST
On Sat, Jun 20, 2026 at 12:39:31PM +0400, Jiawen Liu wrote:
> [You don't often get email from 1298662399@xxxxxx. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> nxp_fspi_probe() enables runtime PM and autosuspend before
> several operations that can fail.
>
> Some failure paths returned directly before the devm cleanup
> action was installed, leaving runtime PM enabled.
>
> Route those failures through a common runtime PM cleanup path.
> Use pm_runtime_resume_and_get() for the initial clock enable.
>
> Signed-off-by: Jiawen Liu <1298662399@xxxxxx>
> ---
> drivers/spi/spi-nxp-fspi.c | 31 ++++++++++++++++++++++---------
> 1 file changed, 22 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/spi/spi-nxp-fspi.c b/drivers/spi/spi-nxp-fspi.c
> index 1e36ae084dd8..d94a2a7b98d4 100644
> --- a/drivers/spi/spi-nxp-fspi.c
> +++ b/drivers/spi/spi-nxp-fspi.c
> @@ -1350,9 +1350,11 @@ static int nxp_fspi_probe(struct platform_device *pdev)
> pm_runtime_use_autosuspend(dev);
>
> /* enable clock */
> - ret = pm_runtime_get_sync(f->dev);
> - if (ret < 0)
> - return dev_err_probe(dev, ret, "Failed to enable clock");
> + ret = pm_runtime_resume_and_get(f->dev);
> + if (ret < 0) {
> + ret = dev_err_probe(dev, ret, "Failed to enable clock");
> + goto err_disable_pm;
> + }
Use PM_RUNTIME_ACQUIRE help macro to avoid all goto
Frank
>
> /* Clear potential interrupts */
> reg = fspi_readl(f, f->iobase + FSPI_INTR);
> @@ -1362,18 +1364,24 @@ static int nxp_fspi_probe(struct platform_device *pdev)
> nxp_fspi_default_setup(f);
>
> ret = pm_runtime_put_sync(dev);
> - if (ret < 0)
> - return dev_err_probe(dev, ret, "Failed to disable clock");
> + if (ret < 0) {
> + ret = dev_err_probe(dev, ret, "Failed to disable clock");
> + goto err_disable_pm;
> + }
>
> init_completion(&f->c);
> ret = devm_request_irq(dev, irq,
> nxp_fspi_irq_handler, 0, pdev->name, f);
> - if (ret)
> - return dev_err_probe(dev, ret, "Failed to request irq\n");
> + if (ret) {
> + ret = dev_err_probe(dev, ret, "Failed to request irq\n");
> + goto err_disable_pm;
> + }
>
> ret = devm_mutex_init(dev, &f->lock);
> - if (ret)
> - return dev_err_probe(dev, ret, "Failed to initialize lock\n");
> + if (ret) {
> + ret = dev_err_probe(dev, ret, "Failed to initialize lock\n");
> + goto err_disable_pm;
> + }
>
> ctlr->bus_num = -1;
> ctlr->num_chipselect = NXP_FSPI_MAX_CHIPSELECT;
> @@ -1389,6 +1397,11 @@ static int nxp_fspi_probe(struct platform_device *pdev)
> return ret;
>
> return devm_spi_register_controller(&pdev->dev, ctlr);
> +
> +err_disable_pm:
> + pm_runtime_dont_use_autosuspend(dev);
> + pm_runtime_disable(dev);
> + return ret;
> }
>
> static int nxp_fspi_runtime_suspend(struct device *dev)
> --
> 2.34.1
>
>