lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250623133402.3120230-7-zhenglifeng1@huawei.com>
Date: Mon, 23 Jun 2025 21:34:01 +0800
From: Lifeng Zheng <zhenglifeng1@...wei.com>
To: <rafael@...nel.org>, <viresh.kumar@...aro.org>, <ionela.voinescu@....com>
CC: <linux-kernel@...r.kernel.org>, <linux-pm@...r.kernel.org>,
	<linuxarm@...wei.com>, <jonathan.cameron@...wei.com>,
	<zhanjie9@...ilicon.com>, <lihuisong@...wei.com>, <yubowen8@...wei.com>,
	<zhenglifeng1@...wei.com>
Subject: [PATCH 6/7] cpufreq: Refactor code about starting governor in cpufreq_set_policy()

Refactor code about starting governor without functional change in
cpufreq_set_policy() to make it more readable.

Signed-off-by: Lifeng Zheng <zhenglifeng1@...wei.com>
---
 drivers/cpufreq/cpufreq.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 9b2578b905a5..7b82ffb50283 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -2698,15 +2698,19 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy,
 	/* start new governor */
 	policy->governor = new_gov;
 	ret = cpufreq_init_governor(policy);
-	if (!ret) {
-		ret = cpufreq_start_governor(policy);
-		if (!ret) {
-			pr_debug("governor change\n");
-			return 0;
-		}
+	if (ret)
+		goto start_old_gov;
+
+	ret = cpufreq_start_governor(policy);
+	if (ret) {
 		cpufreq_exit_governor(policy);
+		goto start_old_gov;
 	}
 
+	pr_debug("governor change\n");
+	return 0;
+
+start_old_gov:
 	/* new governor failed, so re-start old one */
 	pr_debug("starting governor %s failed\n", policy->governor->name);
 	if (old_gov) {
-- 
2.33.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ