2021-05-21 09:37:34

by Tian Tao

[permalink] [raw]
Subject: [PATCH] hwrng: exynos: Use pm_runtime_resume_and_get() to replace open coding

use pm_runtime_resume_and_get() to replace pm_runtime_get_sync and
pm_runtime_put_noidle. this change is just to simplify the code, no
actual functional changes.

Signed-off-by: Tian Tao <[email protected]>
---
drivers/char/hw_random/exynos-trng.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/char/hw_random/exynos-trng.c b/drivers/char/hw_random/exynos-trng.c
index 8e1fe3f..d71ef3c 100644
--- a/drivers/char/hw_random/exynos-trng.c
+++ b/drivers/char/hw_random/exynos-trng.c
@@ -196,10 +196,9 @@ static int __maybe_unused exynos_trng_resume(struct device *dev)
{
int ret;

- ret = pm_runtime_get_sync(dev);
- if (ret < 0) {
+ ret = pm_runtime_resume_and_get(dev);
+ if (ret) {
dev_err(dev, "Could not get runtime PM.\n");
- pm_runtime_put_noidle(dev);
return ret;
}

--
2.7.4


2021-05-21 12:23:55

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH] hwrng: exynos: Use pm_runtime_resume_and_get() to replace open coding

On 20/05/2021 23:58, Tian Tao wrote:
> use pm_runtime_resume_and_get() to replace pm_runtime_get_sync and
> pm_runtime_put_noidle. this change is just to simplify the code, no
> actual functional changes.
>
> Signed-off-by: Tian Tao <[email protected]>
> ---
> drivers/char/hw_random/exynos-trng.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/char/hw_random/exynos-trng.c b/drivers/char/hw_random/exynos-trng.c
> index 8e1fe3f..d71ef3c 100644
> --- a/drivers/char/hw_random/exynos-trng.c
> +++ b/drivers/char/hw_random/exynos-trng.c
> @@ -196,10 +196,9 @@ static int __maybe_unused exynos_trng_resume(struct device *dev)
> {
> int ret;
>
> - ret = pm_runtime_get_sync(dev);
> - if (ret < 0) {
> + ret = pm_runtime_resume_and_get(dev);
> + if (ret) {
> dev_err(dev, "Could not get runtime PM.\n");
> - pm_runtime_put_noidle(dev);
> return ret;

Reviewed-by: Krzysztof Kozlowski <[email protected]>


Best regards,
Krzysztof

2021-05-24 08:33:19

by Łukasz Stelmach

[permalink] [raw]
Subject: Re: [PATCH] hwrng: exynos: Use pm_runtime_resume_and_get() to replace open coding

It was <2021-05-21 pią 11:58>, when Tian Tao wrote:
> use pm_runtime_resume_and_get() to replace pm_runtime_get_sync and
> pm_runtime_put_noidle. this change is just to simplify the code, no
> actual functional changes.
>
> Signed-off-by: Tian Tao <[email protected]>
> ---
> drivers/char/hw_random/exynos-trng.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/char/hw_random/exynos-trng.c b/drivers/char/hw_random/exynos-trng.c
> index 8e1fe3f..d71ef3c 100644
> --- a/drivers/char/hw_random/exynos-trng.c
> +++ b/drivers/char/hw_random/exynos-trng.c
> @@ -196,10 +196,9 @@ static int __maybe_unused exynos_trng_resume(struct device *dev)
> {
> int ret;
>
> - ret = pm_runtime_get_sync(dev);
> - if (ret < 0) {
> + ret = pm_runtime_resume_and_get(dev);
> + if (ret) {

pm_runtime_resume_and_get() (see include/linux/pm_runtime.h) checks for
ret < 0 and returns it, so I think it is better to keep (ret < 0).

> dev_err(dev, "Could not get runtime PM.\n");
> - pm_runtime_put_noidle(dev);
> return ret;
> }

--
Łukasz Stelmach
Samsung R&D Institute Poland
Samsung Electronics


Attachments:
signature.asc (497.00 B)