hwrng: exynos - Fix runtime PM imbalance on error
authorŁukasz Stelmach <l.stelmach@samsung.com>
Wed, 5 May 2021 18:29:14 +0000 (20:29 +0200)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 14 May 2021 11:07:56 +0000 (19:07 +0800)
pm_runtime_resume_and_get() wraps around pm_runtime_get_sync() and
decrements the runtime PM usage counter in case the latter function
fails and keeps the counter balanced.

Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/char/hw_random/exynos-trng.c

index 8e1fe3f8dd2df6c232ac462e017b0817fb3cfaf5..c8db62bc5ff7205ff15949bcb08e627412088346 100644 (file)
@@ -132,7 +132,7 @@ static int exynos_trng_probe(struct platform_device *pdev)
                return PTR_ERR(trng->mem);
 
        pm_runtime_enable(&pdev->dev);
-       ret = pm_runtime_get_sync(&pdev->dev);
+       ret = pm_runtime_resume_and_get(&pdev->dev);
        if (ret < 0) {
                dev_err(&pdev->dev, "Could not get runtime PM.\n");
                goto err_pm_get;
@@ -165,7 +165,7 @@ err_register:
        clk_disable_unprepare(trng->clk);
 
 err_clock:
-       pm_runtime_put_sync(&pdev->dev);
+       pm_runtime_put_noidle(&pdev->dev);
 
 err_pm_get:
        pm_runtime_disable(&pdev->dev);