diff options
author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2016-03-21 10:46:25 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2016-03-22 18:13:36 -0400 |
commit | 999f572983de5e1a4ee9f42daa51b5448f12dd64 (patch) | |
tree | 39a6d29cef230b193517e076525af964b75163c8 /drivers/cpufreq/cpufreq.c | |
parent | 0a300767e5882ad5b687966c80f9620aa0871be5 (diff) |
cpufreq: Introduce cpufreq_update_current_freq()
Move the part of cpufreq_update_policy() that obtains the current
frequency from the driver and updates policy->cur if necessary to
a separate function, cpufreq_get_current_freq().
That should not introduce functional changes and subsequent change
set will need it.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Diffstat (limited to 'drivers/cpufreq/cpufreq.c')
-rw-r--r-- | drivers/cpufreq/cpufreq.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 43f3912a2ac8..ffdb7fca5bb7 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c | |||
@@ -1487,6 +1487,24 @@ unsigned int cpufreq_get(unsigned int cpu) | |||
1487 | } | 1487 | } |
1488 | EXPORT_SYMBOL(cpufreq_get); | 1488 | EXPORT_SYMBOL(cpufreq_get); |
1489 | 1489 | ||
1490 | static unsigned int cpufreq_update_current_freq(struct cpufreq_policy *policy) | ||
1491 | { | ||
1492 | unsigned int new_freq; | ||
1493 | |||
1494 | new_freq = cpufreq_driver->get(policy->cpu); | ||
1495 | if (!new_freq) | ||
1496 | return 0; | ||
1497 | |||
1498 | if (!policy->cur) { | ||
1499 | pr_debug("cpufreq: Driver did not initialize current freq\n"); | ||
1500 | policy->cur = new_freq; | ||
1501 | } else if (policy->cur != new_freq && has_target()) { | ||
1502 | cpufreq_out_of_sync(policy, new_freq); | ||
1503 | } | ||
1504 | |||
1505 | return new_freq; | ||
1506 | } | ||
1507 | |||
1490 | static struct subsys_interface cpufreq_interface = { | 1508 | static struct subsys_interface cpufreq_interface = { |
1491 | .name = "cpufreq", | 1509 | .name = "cpufreq", |
1492 | .subsys = &cpu_subsys, | 1510 | .subsys = &cpu_subsys, |
@@ -2152,19 +2170,11 @@ int cpufreq_update_policy(unsigned int cpu) | |||
2152 | * -> ask driver for current freq and notify governors about a change | 2170 | * -> ask driver for current freq and notify governors about a change |
2153 | */ | 2171 | */ |
2154 | if (cpufreq_driver->get && !cpufreq_driver->setpolicy) { | 2172 | if (cpufreq_driver->get && !cpufreq_driver->setpolicy) { |
2155 | new_policy.cur = cpufreq_driver->get(cpu); | 2173 | new_policy.cur = cpufreq_update_current_freq(policy); |
2156 | if (WARN_ON(!new_policy.cur)) { | 2174 | if (WARN_ON(!new_policy.cur)) { |
2157 | ret = -EIO; | 2175 | ret = -EIO; |
2158 | goto unlock; | 2176 | goto unlock; |
2159 | } | 2177 | } |
2160 | |||
2161 | if (!policy->cur) { | ||
2162 | pr_debug("Driver did not initialize current freq\n"); | ||
2163 | policy->cur = new_policy.cur; | ||
2164 | } else { | ||
2165 | if (policy->cur != new_policy.cur && has_target()) | ||
2166 | cpufreq_out_of_sync(policy, new_policy.cur); | ||
2167 | } | ||
2168 | } | 2178 | } |
2169 | 2179 | ||
2170 | ret = cpufreq_set_policy(policy, &new_policy); | 2180 | ret = cpufreq_set_policy(policy, &new_policy); |