12 #include <linux/kernel.h>
13 #include <linux/module.h>
24 unsigned int min_freq = ~0;
25 unsigned int max_freq = 0;
31 pr_debug(
"table entry %u is invalid, skipping\n", i);
35 pr_debug(
"table entry %u: %u kHz, %u index\n",
36 i, freq, table[i].
index);
43 policy->
min = policy->
cpuinfo.min_freq = min_freq;
44 policy->
max = policy->
cpuinfo.max_freq = max_freq;
46 if (policy->
min == ~0)
57 unsigned int next_larger = ~0;
59 unsigned int count = 0;
61 pr_debug(
"request for verification of policy (%u - %u kHz) for cpu %u\n",
67 cpufreq_verify_within_limits(policy, policy->
cpuinfo.min_freq,
74 if ((freq >= policy->
min) && (freq <= policy->
max))
76 else if ((next_larger > freq) && (freq > policy->
max))
81 policy->
max = next_larger;
83 cpufreq_verify_within_limits(policy, policy->
cpuinfo.min_freq,
86 pr_debug(
"verification lead to (%u - %u kHz) for cpu %u\n",
96 unsigned int target_freq,
97 unsigned int relation,
110 pr_debug(
"request for target %u kHz (relation: %u) for cpu %u\n",
111 target_freq, relation, policy->
cpu);
129 if ((freq < policy->
min) || (freq > policy->
max))
133 if (freq <= target_freq) {
146 if (freq >= target_freq) {
160 if (optimal.
index > i) {
161 if (suboptimal.
index > i)
163 *index = suboptimal.
index;
165 *index = optimal.
index;
168 table[*index].index);
181 unsigned int cpu = policy->
cpu;
185 if (!
per_cpu(cpufreq_show_table, cpu))
188 table =
per_cpu(cpufreq_show_table, cpu);
195 count +=
sprintf(&buf[count],
"\n");
202 .attr = { .name =
"scaling_available_frequencies",
205 .show = show_available_freqs,
216 pr_debug(
"setting show_table for cpu %u to %p\n", cpu, table);
223 pr_debug(
"clearing show_table for cpu %u\n", cpu);
230 return per_cpu(cpufreq_show_table, cpu);