]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
cpufreq: Move the check of cpufreq_driver->get into cpufreq_verify_current_freq()
authorLifeng Zheng <zhenglifeng1@huawei.com>
Wed, 9 Jul 2025 10:41:44 +0000 (18:41 +0800)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 14 Jul 2025 17:38:10 +0000 (19:38 +0200)
Move the check of cpufreq_driver->get into cpufreq_verify_current_freq() in
case of calling it without check.

Signed-off-by: Lifeng Zheng <zhenglifeng1@huawei.com>
Link: https://patch.msgid.link/20250709104145.2348017-4-zhenglifeng1@huawei.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/cpufreq/cpufreq.c

index 2175d2df95b64957c75d37af82942f41a7d1c93a..84f175a55fc5b961e74a82091cfdc6c549b5b735 100644 (file)
@@ -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);