[PATCH v3 6/7] spi: rockchip: Move to pm_runtime_resume_and_get
Sebastian Reichel
sebastian.reichel at collabora.com
Tue Nov 17 17:53:32 PST 2026
Hi,
On Wed, Nov 18, 2026 at 12:50:20AM +0100, Heiko Stuebner wrote:
> From: Heiko Stuebner <heiko.stuebner at cherry.de>
>
> Currently pm_runtime_get_sync() is used, which increments the usage
> count even if the resume was not successful.
>
> Move to the more modern pm_runtime_resume_and_get() which handles the
> usage counter better.
>
> Signed-off-by: Heiko Stuebner <heiko.stuebner at cherry.de>
> ---
This only makes sense when combined with error handling. Keeping
the use count increased makes more sense for the current code:
pm_runtime_get_sync(); // keep use count increased on failure
random_code();
pm_runtime_put(); // always decrease the RPM use count
Meanwhile your new code would result in double decrease on error:
pm_runtime_resume_and_get(); // only increase use count on success
random_code();
pm_runtime_put(); // always decrease RPM use count
Realistically random_code() will SError anyways without runtime PM,
so it *should* actually be pm_runtime_resume_and_get + error handling:
ret = pm_runtime_resume_and_get();
if (ret)
return ret;
random_code();
pm_runtime_put();
For this pattern pm_runtime_resume_and_get() is better than
pm_runtime_get_sync().
Greetings,
-- Sebastian
> drivers/spi/spi-rockchip.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c
> index 8bb55d52d346..ce1629e5a513 100644
> --- a/drivers/spi/spi-rockchip.c
> +++ b/drivers/spi/spi-rockchip.c
> @@ -255,7 +255,7 @@ static void rockchip_spi_set_cs(struct spi_device *spi, bool enable)
>
> if (cs_asserted) {
> /* Keep things powered as long as CS is asserted */
> - pm_runtime_get_sync(rs->dev);
> + pm_runtime_resume_and_get(rs->dev);
>
> if (spi_get_csgpiod(spi, 0))
> ROCKCHIP_SPI_SET_BITS(rs->regs + ROCKCHIP_SPI_SER, 1);
> @@ -734,7 +734,7 @@ static int rockchip_spi_setup(struct spi_device *spi)
> return -EINVAL;
> }
>
> - pm_runtime_get_sync(rs->dev);
> + pm_runtime_resume_and_get(rs->dev);
>
> cr0 = readl_relaxed(rs->regs + ROCKCHIP_SPI_CTRLR0);
>
> @@ -924,7 +924,7 @@ static void rockchip_spi_remove(struct platform_device *pdev)
> {
> struct spi_controller *ctlr = platform_get_drvdata(pdev);
>
> - pm_runtime_get_sync(&pdev->dev);
> + pm_runtime_resume_and_get(&pdev->dev);
>
> spi_unregister_controller(ctlr);
>
> --
> 2.53.0
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-rockchip/attachments/20261118/3abac2ce/attachment.sig>
More information about the Linux-rockchip
mailing list