Merge tag 'random_for_linus_stable' of git://git.kernel.org/pub/scm/linux/kernel...
[cascardo/linux.git] / drivers / cpufreq / acpi-cpufreq.c
index 32a1505..297e912 100644 (file)
@@ -468,20 +468,17 @@ unsigned int acpi_cpufreq_fast_switch(struct cpufreq_policy *policy,
        struct acpi_cpufreq_data *data = policy->driver_data;
        struct acpi_processor_performance *perf;
        struct cpufreq_frequency_table *entry;
-       unsigned int next_perf_state, next_freq, freq;
+       unsigned int next_perf_state, next_freq, index;
 
        /*
         * Find the closest frequency above target_freq.
-        *
-        * The table is sorted in the reverse order with respect to the
-        * frequency and all of the entries are valid (see the initialization).
         */
-       entry = policy->freq_table;
-       do {
-               entry++;
-               freq = entry->frequency;
-       } while (freq >= target_freq && freq != CPUFREQ_TABLE_END);
-       entry--;
+       if (policy->cached_target_freq == target_freq)
+               index = policy->cached_resolved_idx;
+       else
+               index = cpufreq_table_find_index_dl(policy, target_freq);
+
+       entry = &policy->freq_table[index];
        next_freq = entry->frequency;
        next_perf_state = entry->driver_data;