cpufreq: Add and use cpufreq_for_each_{valid_,}entry_idx()
Pointer subtraction is slow and tedious. Therefore, replace all instances where cpufreq_for_each_{valid_,}entry loops contained such substractions with an iteration macro providing an index to the frequency_table entry. Suggested-by: Al Viro <viro@ZenIV.linux.org.uk> Link: http://lkml.kernel.org/r/20180120020237.GM13338@ZenIV.linux.org.uk Acked-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
This commit is contained in:

committed by
Rafael J. Wysocki

parent
70f6bf2a3b
commit
ffd81dcfef
@@ -139,7 +139,7 @@ static int pas_cpufreq_cpu_init(struct cpufreq_policy *policy)
|
||||
struct cpufreq_frequency_table *pos;
|
||||
const u32 *max_freqp;
|
||||
u32 max_freq;
|
||||
int cur_astate;
|
||||
int cur_astate, idx;
|
||||
struct resource res;
|
||||
struct device_node *cpu, *dn;
|
||||
int err = -ENODEV;
|
||||
@@ -198,9 +198,9 @@ static int pas_cpufreq_cpu_init(struct cpufreq_policy *policy)
|
||||
pr_debug("initializing frequency table\n");
|
||||
|
||||
/* initialize frequency table */
|
||||
cpufreq_for_each_entry(pos, pas_freqs) {
|
||||
cpufreq_for_each_entry_idx(pos, pas_freqs, idx) {
|
||||
pos->frequency = get_astate_freq(pos->driver_data) * 100000;
|
||||
pr_debug("%d: %d\n", (int)(pos - pas_freqs), pos->frequency);
|
||||
pr_debug("%d: %d\n", idx, pos->frequency);
|
||||
}
|
||||
|
||||
cur_astate = get_cur_astate(policy->cpu);
|
||||
|
Reference in New Issue
Block a user