RE: [PATCH] spi: nxp-fspi: fix runtime PM cleanup on probe failure
Bough Chen <[email protected]> Mon, 27 Jul 2026 03:32:37 +0000
| Newsgroups | org.kernel.vger.linux-spi,dev.linux.lists.imx,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <AS8PR04MB867677D43B6D5073C88983B290CC2@AS8PR04MB8676.eurprd04.prod.outlook.com> |
> -----Original Message----- > From: Jiawen Liu <[email protected]> > Sent: 2026年7月26日 13:52 > To: Han Xu <[email protected]>; Bough Chen <[email protected]>; Yogesh > Gaur <[email protected]>; Mark Brown <[email protected]> > Cc: [email protected]; [email protected]; > [email protected]; Jiawen Liu <[email protected]> > Subject: [PATCH] spi: nxp-fspi: fix runtime PM cleanup on probe failure > > nxp_fspi_probe() enables runtime PM before calling pm_runtime_get_sync() > to bring the controller clock on for register initialization. > > If pm_runtime_get_sync() fails, the function currently returns immediately. > That leaves runtime PM enabled and leaves the usage counter incremented. > Clean up the failed get with pm_runtime_put_noidle() and disable runtime > PM before returning the error. > > Signed-off-by: Jiawen Liu <[email protected]> > --- > drivers/spi/spi-nxp-fspi.c | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/drivers/spi/spi-nxp-fspi.c b/drivers/spi/spi-nxp-fspi.c index > 1e36ae084dd8..c6037f3209c5 100644 > --- a/drivers/spi/spi-nxp-fspi.c > +++ b/drivers/spi/spi-nxp-fspi.c > @@ -1352,7 +1352,7 @@ static int nxp_fspi_probe(struct platform_device > *pdev) > /* enable clock */ > ret = pm_runtime_get_sync(f->dev); > if (ret < 0) > - return dev_err_probe(dev, ret, "Failed to enable clock"); > + goto err_pm_runtime; Hi Jiawen, Thanks for your patch! To simplify error handling, I prefer to use devm_pm_runtime_enable() instead, and use new API PM_RUNTIME_ACQUIRE_AUTOSUSPEND(dev, pm) to handle the PM get and auto put case, you can refer to spi-nxp-xspi.c. Regards Haibo Chen > > /* Clear potential interrupts */ > reg = fspi_readl(f, f->iobase + FSPI_INTR); @@ -1389,6 +1389,13 @@ > static int nxp_fspi_probe(struct platform_device *pdev) > return ret; > > return devm_spi_register_controller(&pdev->dev, ctlr); > + > +err_pm_runtime: > + pm_runtime_put_noidle(dev); > + pm_runtime_dont_use_autosuspend(dev); > + pm_runtime_disable(dev); > + > + return dev_err_probe(dev, ret, "Failed to enable clock"); > } > > static int nxp_fspi_runtime_suspend(struct device *dev) > -- > 2.34.1