Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Frank Li <Frank.li@oss.nxp.com>
To: Jiawen Liu <1298662399@qq.com>
Cc: broonie@kernel.org, cl634@andestech.com,
	william.zhang@broadcom.com, kursad.oney@broadcom.com,
	jonas.gorski@gmail.com, bcm-kernel-feedback-list@broadcom.com,
	anand.gore@broadcom.com, f.fainelli@gmail.com, rafal@milecki.pl,
	olteanv@gmail.com, han.xu@nxp.com, haibo.chen@nxp.com,
	yogeshgaur.83@gmail.com, linux-spi@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, imx@lists.linux.dev
Subject: Re: [PATCH 4/4] spi: nxp-fspi: disable runtime PM on probe failures
Date: Sat, 20 Jun 2026 09:09:40 -0500	[thread overview]
Message-ID: <ajafJIPNBOiaISgk@SMW015318> (raw)
In-Reply-To: <tencent_8FC0B8DFAF4AE67AEBA20548045D53A77707@qq.com>

On Sat, Jun 20, 2026 at 12:39:31PM +0400, Jiawen Liu wrote:
> [You don't often get email from 1298662399@qq.com. 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@qq.com>
> ---
>  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
>
>


      reply	other threads:[~2026-06-20 14:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20260620083931.1120616-1-1298662399@qq.com>
2026-06-20  8:39 ` [PATCH 1/4] spi: atcspi200: return error from failed controller suspend Jiawen Liu
2026-06-20  8:39 ` [PATCH 2/4] spi: bcmbca-hsspi: " Jiawen Liu
2026-06-20  8:39 ` [PATCH 3/4] spi: fsl-dspi: clean up after failed suspend and resume Jiawen Liu
2026-06-20  8:39 ` [PATCH 4/4] spi: nxp-fspi: disable runtime PM on probe failures Jiawen Liu
2026-06-20 14:09   ` Frank Li [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ajafJIPNBOiaISgk@SMW015318 \
    --to=frank.li@oss.nxp.com \
    --cc=1298662399@qq.com \
    --cc=anand.gore@broadcom.com \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=broonie@kernel.org \
    --cc=cl634@andestech.com \
    --cc=f.fainelli@gmail.com \
    --cc=haibo.chen@nxp.com \
    --cc=han.xu@nxp.com \
    --cc=imx@lists.linux.dev \
    --cc=jonas.gorski@gmail.com \
    --cc=kursad.oney@broadcom.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=rafal@milecki.pl \
    --cc=william.zhang@broadcom.com \
    --cc=yogeshgaur.83@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox