Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux
[sfrench/cifs-2.6.git] / drivers / cpufreq / cpufreq_stats.c
index d362739a71f3701e42d55f2ef508023c4de96cb2..e75880eb037d3b358b8afcfa80fa5d8b41353610 100644 (file)
@@ -170,11 +170,10 @@ void cpufreq_stats_create_table(struct cpufreq_policy *policy)
        unsigned int i = 0, count = 0, ret = -ENOMEM;
        struct cpufreq_stats *stats;
        unsigned int alloc_size;
        unsigned int i = 0, count = 0, ret = -ENOMEM;
        struct cpufreq_stats *stats;
        unsigned int alloc_size;
-       struct cpufreq_frequency_table *pos, *table;
+       struct cpufreq_frequency_table *pos;
 
 
-       /* We need cpufreq table for creating stats table */
-       table = policy->freq_table;
-       if (unlikely(!table))
+       count = cpufreq_table_count_valid_entries(policy);
+       if (!count)
                return;
 
        /* stats already initialized */
                return;
 
        /* stats already initialized */
@@ -185,10 +184,6 @@ void cpufreq_stats_create_table(struct cpufreq_policy *policy)
        if (!stats)
                return;
 
        if (!stats)
                return;
 
-       /* Find total allocation size */
-       cpufreq_for_each_valid_entry(pos, table)
-               count++;
-
        alloc_size = count * sizeof(int) + count * sizeof(u64);
 
        alloc_size += count * count * sizeof(int);
        alloc_size = count * sizeof(int) + count * sizeof(u64);
 
        alloc_size += count * count * sizeof(int);
@@ -205,7 +200,7 @@ void cpufreq_stats_create_table(struct cpufreq_policy *policy)
        stats->max_state = count;
 
        /* Find valid-unique entries */
        stats->max_state = count;
 
        /* Find valid-unique entries */
-       cpufreq_for_each_valid_entry(pos, table)
+       cpufreq_for_each_valid_entry(pos, policy->freq_table)
                if (freq_table_get_index(stats, pos->frequency) == -1)
                        stats->freq_table[i++] = pos->frequency;
 
                if (freq_table_get_index(stats, pos->frequency) == -1)
                        stats->freq_table[i++] = pos->frequency;