cpufreq: Consolidate cpufreq_update_current_freq() and __cpufreq_get()
Their implementations are quite similar, so modify cpufreq_update_current_freq() somewhat and call it from __cpufreq_get(). Also rename cpufreq_update_current_freq() to cpufreq_verify_current_freq(), as that's what it is doing. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> [ rjw: Subject & changelog ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
This commit is contained in:
parent
9801522840
commit
5980752e6e
|
@ -1545,6 +1545,30 @@ static void cpufreq_out_of_sync(struct cpufreq_policy *policy,
|
||||||
cpufreq_freq_transition_end(policy, &freqs, 0);
|
cpufreq_freq_transition_end(policy, &freqs, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static unsigned int cpufreq_verify_current_freq(struct cpufreq_policy *policy, bool update)
|
||||||
|
{
|
||||||
|
unsigned int new_freq;
|
||||||
|
|
||||||
|
new_freq = cpufreq_driver->get(policy->cpu);
|
||||||
|
if (!new_freq)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If fast frequency switching is used with the given policy, the check
|
||||||
|
* against policy->cur is pointless, so skip it in that case.
|
||||||
|
*/
|
||||||
|
if (policy->fast_switch_enabled || !has_target())
|
||||||
|
return new_freq;
|
||||||
|
|
||||||
|
if (policy->cur != new_freq) {
|
||||||
|
cpufreq_out_of_sync(policy, new_freq);
|
||||||
|
if (update)
|
||||||
|
schedule_work(&policy->update);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new_freq;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cpufreq_quick_get - get the CPU frequency (in kHz) from policy->cur
|
* cpufreq_quick_get - get the CPU frequency (in kHz) from policy->cur
|
||||||
* @cpu: CPU number
|
* @cpu: CPU number
|
||||||
|
@ -1600,30 +1624,10 @@ EXPORT_SYMBOL(cpufreq_quick_get_max);
|
||||||
|
|
||||||
static unsigned int __cpufreq_get(struct cpufreq_policy *policy)
|
static unsigned int __cpufreq_get(struct cpufreq_policy *policy)
|
||||||
{
|
{
|
||||||
unsigned int ret_freq = 0;
|
|
||||||
|
|
||||||
if (unlikely(policy_is_inactive(policy)))
|
if (unlikely(policy_is_inactive(policy)))
|
||||||
return ret_freq;
|
return 0;
|
||||||
|
|
||||||
ret_freq = cpufreq_driver->get(policy->cpu);
|
return cpufreq_verify_current_freq(policy, true);
|
||||||
|
|
||||||
/*
|
|
||||||
* If fast frequency switching is used with the given policy, the check
|
|
||||||
* against policy->cur is pointless, so skip it in that case too.
|
|
||||||
*/
|
|
||||||
if (policy->fast_switch_enabled)
|
|
||||||
return ret_freq;
|
|
||||||
|
|
||||||
if (has_target() && ret_freq && policy->cur) {
|
|
||||||
/* verify no discrepancy between actual and
|
|
||||||
saved value exists */
|
|
||||||
if (unlikely(ret_freq != policy->cur)) {
|
|
||||||
cpufreq_out_of_sync(policy, ret_freq);
|
|
||||||
schedule_work(&policy->update);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret_freq;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1650,24 +1654,6 @@ unsigned int cpufreq_get(unsigned int cpu)
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(cpufreq_get);
|
EXPORT_SYMBOL(cpufreq_get);
|
||||||
|
|
||||||
static unsigned int cpufreq_update_current_freq(struct cpufreq_policy *policy)
|
|
||||||
{
|
|
||||||
unsigned int new_freq;
|
|
||||||
|
|
||||||
new_freq = cpufreq_driver->get(policy->cpu);
|
|
||||||
if (!new_freq)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (!policy->cur) {
|
|
||||||
pr_debug("cpufreq: Driver did not initialize current freq\n");
|
|
||||||
policy->cur = new_freq;
|
|
||||||
} else if (policy->cur != new_freq && has_target()) {
|
|
||||||
cpufreq_out_of_sync(policy, new_freq);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new_freq;
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct subsys_interface cpufreq_interface = {
|
static struct subsys_interface cpufreq_interface = {
|
||||||
.name = "cpufreq",
|
.name = "cpufreq",
|
||||||
.subsys = &cpu_subsys,
|
.subsys = &cpu_subsys,
|
||||||
|
@ -2149,7 +2135,7 @@ static int cpufreq_start_governor(struct cpufreq_policy *policy)
|
||||||
pr_debug("%s: for CPU %u\n", __func__, policy->cpu);
|
pr_debug("%s: for CPU %u\n", __func__, policy->cpu);
|
||||||
|
|
||||||
if (cpufreq_driver->get)
|
if (cpufreq_driver->get)
|
||||||
cpufreq_update_current_freq(policy);
|
cpufreq_verify_current_freq(policy, false);
|
||||||
|
|
||||||
if (policy->governor->start) {
|
if (policy->governor->start) {
|
||||||
ret = policy->governor->start(policy);
|
ret = policy->governor->start(policy);
|
||||||
|
@ -2400,7 +2386,7 @@ void cpufreq_update_policy(unsigned int cpu)
|
||||||
* -> ask driver for current freq and notify governors about a change
|
* -> ask driver for current freq and notify governors about a change
|
||||||
*/
|
*/
|
||||||
if (cpufreq_driver->get && has_target() &&
|
if (cpufreq_driver->get && has_target() &&
|
||||||
(cpufreq_suspended || WARN_ON(!cpufreq_update_current_freq(policy))))
|
(cpufreq_suspended || WARN_ON(!cpufreq_verify_current_freq(policy, false))))
|
||||||
goto unlock;
|
goto unlock;
|
||||||
|
|
||||||
pr_debug("updating policy for CPU %u\n", cpu);
|
pr_debug("updating policy for CPU %u\n", cpu);
|
||||||
|
|
Loading…
Reference in New Issue