[PATCH 4/7] cpufreq: Remove duplicate check in __cpufreq_offline()

Lifeng Zheng posted 7 patches 3 months, 2 weeks ago
[PATCH 4/7] cpufreq: Remove duplicate check in __cpufreq_offline()
Posted by Lifeng Zheng 3 months, 2 weeks ago
The has_target() checks in __cpufreq_offline() are duplicate. Remove one of
them and put the operations of exiting governor together with storing last
governor's name.

Signed-off-by: Lifeng Zheng <zhenglifeng1@huawei.com>
---
 drivers/cpufreq/cpufreq.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 2303890de0ba..c4891bf5dc84 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1692,14 +1692,13 @@ static void __cpufreq_offline(unsigned int cpu, struct cpufreq_policy *policy)
 		return;
 	}
 
-	if (has_target())
+	if (has_target()) {
 		strscpy(policy->last_governor, policy->governor->name,
 			CPUFREQ_NAME_LEN);
-	else
-		policy->last_policy = policy->policy;
-
-	if (has_target())
 		cpufreq_exit_governor(policy);
+	} else {
+		policy->last_policy = policy->policy;
+	}
 
 	/*
 	 * Perform the ->offline() during light-weight tear-down, as
-- 
2.33.0
Re: [PATCH 4/7] cpufreq: Remove duplicate check in __cpufreq_offline()
Posted by Rafael J. Wysocki 3 months, 2 weeks ago
On Mon, Jun 23, 2025 at 3:34 PM Lifeng Zheng <zhenglifeng1@huawei.com> wrote:
>
> The has_target() checks in __cpufreq_offline() are duplicate. Remove one of
> them and put the operations of exiting governor together with storing last
> governor's name.
>
> Signed-off-by: Lifeng Zheng <zhenglifeng1@huawei.com>
> ---
>  drivers/cpufreq/cpufreq.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index 2303890de0ba..c4891bf5dc84 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -1692,14 +1692,13 @@ static void __cpufreq_offline(unsigned int cpu, struct cpufreq_policy *policy)
>                 return;
>         }
>
> -       if (has_target())
> +       if (has_target()) {
>                 strscpy(policy->last_governor, policy->governor->name,
>                         CPUFREQ_NAME_LEN);
> -       else
> -               policy->last_policy = policy->policy;
> -
> -       if (has_target())
>                 cpufreq_exit_governor(policy);
> +       } else {
> +               policy->last_policy = policy->policy;
> +       }
>
>         /*
>          * Perform the ->offline() during light-weight tear-down, as
> --

This is fine by me, thanks!