diff options
Diffstat (limited to 'drivers/cpufreq/cpufreq_stats.c')
-rw-r--r-- | drivers/cpufreq/cpufreq_stats.c | 31 |
1 files changed, 8 insertions, 23 deletions
diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c index d37568c5ca9c..04452f026ed0 100644 --- a/drivers/cpufreq/cpufreq_stats.c +++ b/drivers/cpufreq/cpufreq_stats.c | |||
@@ -9,17 +9,10 @@ | |||
9 | * published by the Free Software Foundation. | 9 | * published by the Free Software Foundation. |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #include <linux/kernel.h> | ||
13 | #include <linux/slab.h> | ||
14 | #include <linux/cpu.h> | 12 | #include <linux/cpu.h> |
15 | #include <linux/sysfs.h> | ||
16 | #include <linux/cpufreq.h> | 13 | #include <linux/cpufreq.h> |
17 | #include <linux/module.h> | 14 | #include <linux/module.h> |
18 | #include <linux/jiffies.h> | 15 | #include <linux/slab.h> |
19 | #include <linux/percpu.h> | ||
20 | #include <linux/kobject.h> | ||
21 | #include <linux/spinlock.h> | ||
22 | #include <linux/notifier.h> | ||
23 | #include <asm/cputime.h> | 16 | #include <asm/cputime.h> |
24 | 17 | ||
25 | static spinlock_t cpufreq_stats_lock; | 18 | static spinlock_t cpufreq_stats_lock; |
@@ -200,22 +193,22 @@ static int cpufreq_stats_create_table(struct cpufreq_policy *policy, | |||
200 | { | 193 | { |
201 | unsigned int i, j, count = 0, ret = 0; | 194 | unsigned int i, j, count = 0, ret = 0; |
202 | struct cpufreq_stats *stat; | 195 | struct cpufreq_stats *stat; |
203 | struct cpufreq_policy *data; | 196 | struct cpufreq_policy *current_policy; |
204 | unsigned int alloc_size; | 197 | unsigned int alloc_size; |
205 | unsigned int cpu = policy->cpu; | 198 | unsigned int cpu = policy->cpu; |
206 | if (per_cpu(cpufreq_stats_table, cpu)) | 199 | if (per_cpu(cpufreq_stats_table, cpu)) |
207 | return -EBUSY; | 200 | return -EBUSY; |
208 | stat = kzalloc(sizeof(struct cpufreq_stats), GFP_KERNEL); | 201 | stat = kzalloc(sizeof(*stat), GFP_KERNEL); |
209 | if ((stat) == NULL) | 202 | if ((stat) == NULL) |
210 | return -ENOMEM; | 203 | return -ENOMEM; |
211 | 204 | ||
212 | data = cpufreq_cpu_get(cpu); | 205 | current_policy = cpufreq_cpu_get(cpu); |
213 | if (data == NULL) { | 206 | if (current_policy == NULL) { |
214 | ret = -EINVAL; | 207 | ret = -EINVAL; |
215 | goto error_get_fail; | 208 | goto error_get_fail; |
216 | } | 209 | } |
217 | 210 | ||
218 | ret = sysfs_create_group(&data->kobj, &stats_attr_group); | 211 | ret = sysfs_create_group(¤t_policy->kobj, &stats_attr_group); |
219 | if (ret) | 212 | if (ret) |
220 | goto error_out; | 213 | goto error_out; |
221 | 214 | ||
@@ -258,10 +251,10 @@ static int cpufreq_stats_create_table(struct cpufreq_policy *policy, | |||
258 | stat->last_time = get_jiffies_64(); | 251 | stat->last_time = get_jiffies_64(); |
259 | stat->last_index = freq_table_get_index(stat, policy->cur); | 252 | stat->last_index = freq_table_get_index(stat, policy->cur); |
260 | spin_unlock(&cpufreq_stats_lock); | 253 | spin_unlock(&cpufreq_stats_lock); |
261 | cpufreq_cpu_put(data); | 254 | cpufreq_cpu_put(current_policy); |
262 | return 0; | 255 | return 0; |
263 | error_out: | 256 | error_out: |
264 | cpufreq_cpu_put(data); | 257 | cpufreq_cpu_put(current_policy); |
265 | error_get_fail: | 258 | error_get_fail: |
266 | kfree(stat); | 259 | kfree(stat); |
267 | per_cpu(cpufreq_stats_table, cpu) = NULL; | 260 | per_cpu(cpufreq_stats_table, cpu) = NULL; |
@@ -348,16 +341,10 @@ static int cpufreq_stat_cpu_callback(struct notifier_block *nfb, | |||
348 | unsigned int cpu = (unsigned long)hcpu; | 341 | unsigned int cpu = (unsigned long)hcpu; |
349 | 342 | ||
350 | switch (action) { | 343 | switch (action) { |
351 | case CPU_ONLINE: | ||
352 | case CPU_ONLINE_FROZEN: | ||
353 | cpufreq_update_policy(cpu); | ||
354 | break; | ||
355 | case CPU_DOWN_PREPARE: | 344 | case CPU_DOWN_PREPARE: |
356 | case CPU_DOWN_PREPARE_FROZEN: | ||
357 | cpufreq_stats_free_sysfs(cpu); | 345 | cpufreq_stats_free_sysfs(cpu); |
358 | break; | 346 | break; |
359 | case CPU_DEAD: | 347 | case CPU_DEAD: |
360 | case CPU_DEAD_FROZEN: | ||
361 | cpufreq_stats_free_table(cpu); | 348 | cpufreq_stats_free_table(cpu); |
362 | break; | 349 | break; |
363 | } | 350 | } |
@@ -390,8 +377,6 @@ static int __init cpufreq_stats_init(void) | |||
390 | return ret; | 377 | return ret; |
391 | 378 | ||
392 | register_hotcpu_notifier(&cpufreq_stat_cpu_notifier); | 379 | register_hotcpu_notifier(&cpufreq_stat_cpu_notifier); |
393 | for_each_online_cpu(cpu) | ||
394 | cpufreq_update_policy(cpu); | ||
395 | 380 | ||
396 | ret = cpufreq_register_notifier(¬ifier_trans_block, | 381 | ret = cpufreq_register_notifier(¬ifier_trans_block, |
397 | CPUFREQ_TRANSITION_NOTIFIER); | 382 | CPUFREQ_TRANSITION_NOTIFIER); |