mirror of
https://github.com/torvalds/linux.git
synced 2024-11-28 07:01:32 +00:00
[CPUFREQ] cpufreq_notify_transition cleanup.
Introduce caching of cpufreq_cpu_data[freqs->cpu], which allows us to make the function a lot more readable, and as a nice side-effect, it now fits in < 80 column displays again. Signed-off-by: Dave Jones <davej@redhat.com>
This commit is contained in:
parent
c067286019
commit
e4472cb370
@ -229,44 +229,53 @@ static inline void adjust_jiffies(unsigned long val, struct cpufreq_freqs *ci) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cpufreq_notify_transition - call notifier chain and adjust_jiffies on frequency transition
|
* cpufreq_notify_transition - call notifier chain and adjust_jiffies
|
||||||
|
* on frequency transition.
|
||||||
*
|
*
|
||||||
* This function calls the transition notifiers and the "adjust_jiffies" function. It is called
|
* This function calls the transition notifiers and the "adjust_jiffies"
|
||||||
* twice on all CPU frequency changes that have external effects.
|
* function. It is called twice on all CPU frequency changes that have
|
||||||
|
* external effects.
|
||||||
*/
|
*/
|
||||||
void cpufreq_notify_transition(struct cpufreq_freqs *freqs, unsigned int state)
|
void cpufreq_notify_transition(struct cpufreq_freqs *freqs, unsigned int state)
|
||||||
{
|
{
|
||||||
|
struct cpufreq_policy *policy;
|
||||||
|
|
||||||
BUG_ON(irqs_disabled());
|
BUG_ON(irqs_disabled());
|
||||||
|
|
||||||
freqs->flags = cpufreq_driver->flags;
|
freqs->flags = cpufreq_driver->flags;
|
||||||
dprintk("notification %u of frequency transition to %u kHz\n", state, freqs->new);
|
dprintk("notification %u of frequency transition to %u kHz\n",
|
||||||
|
state, freqs->new);
|
||||||
|
|
||||||
down_read(&cpufreq_notifier_rwsem);
|
down_read(&cpufreq_notifier_rwsem);
|
||||||
|
|
||||||
|
policy = cpufreq_cpu_data[freqs->cpu];
|
||||||
switch (state) {
|
switch (state) {
|
||||||
|
|
||||||
case CPUFREQ_PRECHANGE:
|
case CPUFREQ_PRECHANGE:
|
||||||
/* detect if the driver reported a value as "old frequency" which
|
/* detect if the driver reported a value as "old frequency"
|
||||||
* is not equal to what the cpufreq core thinks is "old frequency".
|
* which is not equal to what the cpufreq core thinks is
|
||||||
|
* "old frequency".
|
||||||
*/
|
*/
|
||||||
if (!(cpufreq_driver->flags & CPUFREQ_CONST_LOOPS)) {
|
if (!(cpufreq_driver->flags & CPUFREQ_CONST_LOOPS)) {
|
||||||
if ((likely(cpufreq_cpu_data[freqs->cpu])) &&
|
if ((policy) && (policy->cpu == freqs->cpu) &&
|
||||||
(likely(cpufreq_cpu_data[freqs->cpu]->cpu == freqs->cpu)) &&
|
(policy->cur) && (policy->cur != freqs->old)) {
|
||||||
(likely(cpufreq_cpu_data[freqs->cpu]->cur)) &&
|
dprintk(KERN_WARNING "Warning: CPU frequency is"
|
||||||
(unlikely(freqs->old != cpufreq_cpu_data[freqs->cpu]->cur)))
|
" %u, cpufreq assumed %u kHz.\n",
|
||||||
{
|
freqs->old, policy->cur);
|
||||||
dprintk(KERN_WARNING "Warning: CPU frequency is %u, "
|
freqs->old = policy->cur;
|
||||||
"cpufreq assumed %u kHz.\n", freqs->old, cpufreq_cpu_data[freqs->cpu]->cur);
|
|
||||||
freqs->old = cpufreq_cpu_data[freqs->cpu]->cur;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
notifier_call_chain(&cpufreq_transition_notifier_list, CPUFREQ_PRECHANGE, freqs);
|
notifier_call_chain(&cpufreq_transition_notifier_list,
|
||||||
|
CPUFREQ_PRECHANGE, freqs);
|
||||||
adjust_jiffies(CPUFREQ_PRECHANGE, freqs);
|
adjust_jiffies(CPUFREQ_PRECHANGE, freqs);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CPUFREQ_POSTCHANGE:
|
case CPUFREQ_POSTCHANGE:
|
||||||
adjust_jiffies(CPUFREQ_POSTCHANGE, freqs);
|
adjust_jiffies(CPUFREQ_POSTCHANGE, freqs);
|
||||||
notifier_call_chain(&cpufreq_transition_notifier_list, CPUFREQ_POSTCHANGE, freqs);
|
notifier_call_chain(&cpufreq_transition_notifier_list,
|
||||||
if ((likely(cpufreq_cpu_data[freqs->cpu])) &&
|
CPUFREQ_POSTCHANGE, freqs);
|
||||||
(likely(cpufreq_cpu_data[freqs->cpu]->cpu == freqs->cpu)))
|
if (likely(policy) && likely(policy->cpu == freqs->cpu))
|
||||||
cpufreq_cpu_data[freqs->cpu]->cur = freqs->new;
|
policy->cur = freqs->new;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
up_read(&cpufreq_notifier_rwsem);
|
up_read(&cpufreq_notifier_rwsem);
|
||||||
|
Loading…
Reference in New Issue
Block a user