aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLifeng Zheng <[email protected]>2025-07-09 10:41:44 +0000
committerRafael J. Wysocki <[email protected]>2025-07-14 17:38:10 +0000
commit908981d85f86c5e2b39dfe0b2267c6d44d9c48f7 (patch)
treefc9366da15d9b326770bb6db7bb1266a03ffbd50
parentcpufreq: Init policy->rwsem before it may be possibly used (diff)
downloadkernel-908981d85f86c5e2b39dfe0b2267c6d44d9c48f7.tar.gz
kernel-908981d85f86c5e2b39dfe0b2267c6d44d9c48f7.zip
cpufreq: Move the check of cpufreq_driver->get into cpufreq_verify_current_freq()
Move the check of cpufreq_driver->get into cpufreq_verify_current_freq() in case of calling it without check. Signed-off-by: Lifeng Zheng <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Rafael J. Wysocki <[email protected]>
-rw-r--r--drivers/cpufreq/cpufreq.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 2175d2df95b6..84f175a55fc5 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1800,6 +1800,9 @@ static unsigned int cpufreq_verify_current_freq(struct cpufreq_policy *policy, b
{
unsigned int new_freq;
+ if (!cpufreq_driver->get)
+ return 0;
+
new_freq = cpufreq_driver->get(policy->cpu);
if (!new_freq)
return 0;
@@ -1922,10 +1925,7 @@ unsigned int cpufreq_get(unsigned int cpu)
guard(cpufreq_policy_read)(policy);
- if (cpufreq_driver->get)
- return __cpufreq_get(policy);
-
- return 0;
+ return __cpufreq_get(policy);
}
EXPORT_SYMBOL(cpufreq_get);
@@ -2479,8 +2479,7 @@ int cpufreq_start_governor(struct cpufreq_policy *policy)
pr_debug("%s: for CPU %u\n", __func__, policy->cpu);
- if (cpufreq_driver->get)
- cpufreq_verify_current_freq(policy, false);
+ cpufreq_verify_current_freq(policy, false);
if (policy->governor->start) {
ret = policy->governor->start(policy);