[PATCH v3 2/2] cpufreq: cpufreq_boost_trigger_state() optimization

From: Lifeng Zheng

Date: Tue Dec 02 2025 - 02:28:02 EST


Optimize the error handling branch code in cpufreq_boost_trigger_state().

Signed-off-by: Lifeng Zheng <zhenglifeng1@xxxxxxxxxx>
Acked-by: Viresh Kumar <viresh.kumar@xxxxxxxxxx>
---
drivers/cpufreq/cpufreq.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index a4399e5490da..a2507a5b42d9 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -2823,19 +2823,14 @@ static int cpufreq_boost_trigger_state(int state)
continue;

ret = policy_set_boost(policy, state);
- if (ret)
- goto err_reset_state;
+ if (unlikely(ret))
+ break;
}

- if (ret)
- goto err_reset_state;
-
cpus_read_unlock();

- return 0;
-
-err_reset_state:
- cpus_read_unlock();
+ if (likely(!ret))
+ return 0;

write_lock_irqsave(&cpufreq_driver_lock, flags);
cpufreq_driver->boost_enabled = !state;
--
2.33.0