static unsigned int choose_freq( struct cpufreq_interactive_cpuinfo *pcpu, unsigned int loadadjfreq) { unsigned int freq = pcpu->policy->cur; unsigned int prevfreq, freqmin, freqmax; unsigned int tl; int index; freqmin = 0; freqmax = UINT_MAX; do { prevfreq = freq; tl = freq_to_targetload(freq); /* * Find the lowest frequency where the computed load is less * than or equal to the target load. */ if (cpufreq_frequency_table_target( pcpu->policy, pcpu->freq_table, loadadjfreq / tl, CPUFREQ_RELATION_L, &index)) break; freq = pcpu->freq_table[index].frequency; if (freq > prevfreq) { /* The previous frequency is too low. */ freqmin = prevfreq; if (freq >= freqmax) { /* * Find the highest frequency that is less * than freqmax. */ if (cpufreq_frequency_table_target( pcpu->policy, pcpu->freq_table, freqmax - 1, CPUFREQ_RELATION_H, &index)) break; freq = pcpu->freq_table[index].frequency; if (freq == freqmin) { /* * The first frequency below freqmax * has already been found to be too * low. freqmax is the lowest speed * we found that is fast enough. */ freq = freqmax; break; } } } else if (freq < prevfreq) { /* The previous frequency is high enough. */ freqmax = prevfreq; if (freq <= freqmin) { /* * Find the lowest frequency that is higher * than freqmin. */ if (cpufreq_frequency_table_target( pcpu->policy, pcpu->freq_table, freqmin + 1, CPUFREQ_RELATION_L, &index)) break; freq = pcpu->freq_table[index].frequency; /* * If freqmax is the first frequency above * freqmin then we have already found that * this speed is fast enough. */ if (freq == freqmax) break; } } /* If same frequency chosen as previous then done. */ } while (freq != prevfreq); return freq; }
static unsigned int choose_freq(struct cpufreq_interactive_cpuinfo *pcpu, unsigned int loadadjfreq) { unsigned int freq = pcpu->policy->cur; unsigned int prevfreq, freqmin, freqmax; unsigned int tl; int index; freqmin = 0; freqmax = UINT_MAX; do { prevfreq = freq; tl = freq_to_targetload(pcpu->policy->governor_data, freq); if (cpufreq_frequency_table_target( pcpu->policy, pcpu->freq_table, loadadjfreq / tl, CPUFREQ_RELATION_L, &index)) break; freq = pcpu->freq_table[index].frequency; if (freq > prevfreq) { freqmin = prevfreq; if (freq >= freqmax) { if (cpufreq_frequency_table_target( pcpu->policy, pcpu->freq_table, freqmax - 1, CPUFREQ_RELATION_H, &index)) break; freq = pcpu->freq_table[index].frequency; if (freq == freqmin) { freq = freqmax; break; } } } else if (freq < prevfreq) { freqmax = prevfreq; if (freq <= freqmin) { if (cpufreq_frequency_table_target( pcpu->policy, pcpu->freq_table, freqmin + 1, CPUFREQ_RELATION_L, &index)) break; freq = pcpu->freq_table[index].frequency; if (freq == freqmax) break; } } } while (freq != prevfreq); return freq; }