diff mbox series

[v2] hwrng: exynos - Fix runtime PM imbalance on error

Message ID 20200522011659.26727-1-dinghao.liu@zju.edu.cn (mailing list archive)
State New, archived
Headers show
Series [v2] hwrng: exynos - Fix runtime PM imbalance on error | expand

Commit Message

Dinghao Liu May 22, 2020, 1:16 a.m. UTC
pm_runtime_get_sync() increments the runtime PM usage counter even
when it returns an error code. Thus a pairing decrement is needed on
the error handling path to keep the counter balanced.

Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
---

Changelog:

v2: -- Remove unnecessary 'err_clock' label
---
 drivers/char/hw_random/exynos-trng.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

Comments

Łukasz Stelmach May 22, 2020, 9:07 a.m. UTC | #1
It was <2020-05-22 pią 09:16>, when Dinghao Liu wrote:
> pm_runtime_get_sync() increments the runtime PM usage counter even
> when it returns an error code. Thus a pairing decrement is needed on
> the error handling path to keep the counter balanced.
>
> Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
> ---
>
> Changelog:
>
> v2: -- Remove unnecessary 'err_clock' label
> ---
>  drivers/char/hw_random/exynos-trng.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
>

Reviewed-by: Lukasz Stelmach <l.stelmach@samsung.com>


Thank you.

> diff --git a/drivers/char/hw_random/exynos-trng.c b/drivers/char/hw_random/exynos-trng.c
> index 8e1fe3f8dd2d..8393b898a50e 100644
> --- a/drivers/char/hw_random/exynos-trng.c
> +++ b/drivers/char/hw_random/exynos-trng.c
> @@ -142,13 +142,13 @@ static int exynos_trng_probe(struct platform_device *pdev)
>  	if (IS_ERR(trng->clk)) {
>  		ret = PTR_ERR(trng->clk);
>  		dev_err(&pdev->dev, "Could not get clock.\n");
> -		goto err_clock;
> +		goto err_pm_get;
>  	}
>  
>  	ret = clk_prepare_enable(trng->clk);
>  	if (ret) {
>  		dev_err(&pdev->dev, "Could not enable the clk.\n");
> -		goto err_clock;
> +		goto err_pm_get;
>  	}
>  
>  	ret = devm_hwrng_register(&pdev->dev, &trng->rng);
> @@ -164,10 +164,8 @@ static int exynos_trng_probe(struct platform_device *pdev)
>  err_register:
>  	clk_disable_unprepare(trng->clk);
>  
> -err_clock:
> -	pm_runtime_put_sync(&pdev->dev);
> -
>  err_pm_get:
> +	pm_runtime_put_sync(&pdev->dev);
>  	pm_runtime_disable(&pdev->dev);
>  
>  	return ret;
diff mbox series

Patch

diff --git a/drivers/char/hw_random/exynos-trng.c b/drivers/char/hw_random/exynos-trng.c
index 8e1fe3f8dd2d..8393b898a50e 100644
--- a/drivers/char/hw_random/exynos-trng.c
+++ b/drivers/char/hw_random/exynos-trng.c
@@ -142,13 +142,13 @@  static int exynos_trng_probe(struct platform_device *pdev)
 	if (IS_ERR(trng->clk)) {
 		ret = PTR_ERR(trng->clk);
 		dev_err(&pdev->dev, "Could not get clock.\n");
-		goto err_clock;
+		goto err_pm_get;
 	}
 
 	ret = clk_prepare_enable(trng->clk);
 	if (ret) {
 		dev_err(&pdev->dev, "Could not enable the clk.\n");
-		goto err_clock;
+		goto err_pm_get;
 	}
 
 	ret = devm_hwrng_register(&pdev->dev, &trng->rng);
@@ -164,10 +164,8 @@  static int exynos_trng_probe(struct platform_device *pdev)
 err_register:
 	clk_disable_unprepare(trng->clk);
 
-err_clock:
-	pm_runtime_put_sync(&pdev->dev);
-
 err_pm_get:
+	pm_runtime_put_sync(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
 
 	return ret;