diff options
author | Mike Travis <travis@sgi.com> | 2008-03-25 18:06:53 -0400 |
---|---|---|
committer | Dave Jones <davej@redhat.com> | 2008-05-19 18:17:49 -0400 |
commit | 7a6aedfac98c6d54ecf97ca1ffb1e6a1f3d26aea (patch) | |
tree | 404f941cae556ce45b53c90bb4192d9fb53bd233 /drivers/cpufreq/cpufreq_stats.c | |
parent | 860da5e578c25d1ab4528c0d1ad13f9969e3490f (diff) |
[CPUFREQ] change cpu freq arrays to per_cpu variables
Change cpufreq_policy and cpufreq_governor pointer tables
from arrays to per_cpu variables in the cpufreq subsystem.
Also some minor complaints from checkpatch.pl fixed.
Based on:
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
git://git.kernel.org/pub/scm/linux/kernel/git/x86/linux-2.6-x86.git
Signed-off-by: Mike Travis <travis@sgi.com>
Signed-off-by: Dave Jones <davej@redhat.com>
Diffstat (limited to 'drivers/cpufreq/cpufreq_stats.c')
-rw-r--r-- | drivers/cpufreq/cpufreq_stats.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c index ae70d63a8b26..c0ff97d375d7 100644 --- a/drivers/cpufreq/cpufreq_stats.c +++ b/drivers/cpufreq/cpufreq_stats.c | |||
@@ -43,7 +43,7 @@ struct cpufreq_stats { | |||
43 | #endif | 43 | #endif |
44 | }; | 44 | }; |
45 | 45 | ||
46 | static struct cpufreq_stats *cpufreq_stats_table[NR_CPUS]; | 46 | static DEFINE_PER_CPU(struct cpufreq_stats *, cpufreq_stats_table); |
47 | 47 | ||
48 | struct cpufreq_stats_attribute { | 48 | struct cpufreq_stats_attribute { |
49 | struct attribute attr; | 49 | struct attribute attr; |
@@ -58,7 +58,7 @@ cpufreq_stats_update (unsigned int cpu) | |||
58 | 58 | ||
59 | cur_time = get_jiffies_64(); | 59 | cur_time = get_jiffies_64(); |
60 | spin_lock(&cpufreq_stats_lock); | 60 | spin_lock(&cpufreq_stats_lock); |
61 | stat = cpufreq_stats_table[cpu]; | 61 | stat = per_cpu(cpufreq_stats_table, cpu); |
62 | if (stat->time_in_state) | 62 | if (stat->time_in_state) |
63 | stat->time_in_state[stat->last_index] = | 63 | stat->time_in_state[stat->last_index] = |
64 | cputime64_add(stat->time_in_state[stat->last_index], | 64 | cputime64_add(stat->time_in_state[stat->last_index], |
@@ -71,11 +71,11 @@ cpufreq_stats_update (unsigned int cpu) | |||
71 | static ssize_t | 71 | static ssize_t |
72 | show_total_trans(struct cpufreq_policy *policy, char *buf) | 72 | show_total_trans(struct cpufreq_policy *policy, char *buf) |
73 | { | 73 | { |
74 | struct cpufreq_stats *stat = cpufreq_stats_table[policy->cpu]; | 74 | struct cpufreq_stats *stat = per_cpu(cpufreq_stats_table, policy->cpu); |
75 | if (!stat) | 75 | if (!stat) |
76 | return 0; | 76 | return 0; |
77 | return sprintf(buf, "%d\n", | 77 | return sprintf(buf, "%d\n", |
78 | cpufreq_stats_table[stat->cpu]->total_trans); | 78 | per_cpu(cpufreq_stats_table, stat->cpu)->total_trans); |
79 | } | 79 | } |
80 | 80 | ||
81 | static ssize_t | 81 | static ssize_t |
@@ -83,7 +83,7 @@ show_time_in_state(struct cpufreq_policy *policy, char *buf) | |||
83 | { | 83 | { |
84 | ssize_t len = 0; | 84 | ssize_t len = 0; |
85 | int i; | 85 | int i; |
86 | struct cpufreq_stats *stat = cpufreq_stats_table[policy->cpu]; | 86 | struct cpufreq_stats *stat = per_cpu(cpufreq_stats_table, policy->cpu); |
87 | if (!stat) | 87 | if (!stat) |
88 | return 0; | 88 | return 0; |
89 | cpufreq_stats_update(stat->cpu); | 89 | cpufreq_stats_update(stat->cpu); |
@@ -101,7 +101,7 @@ show_trans_table(struct cpufreq_policy *policy, char *buf) | |||
101 | ssize_t len = 0; | 101 | ssize_t len = 0; |
102 | int i, j; | 102 | int i, j; |
103 | 103 | ||
104 | struct cpufreq_stats *stat = cpufreq_stats_table[policy->cpu]; | 104 | struct cpufreq_stats *stat = per_cpu(cpufreq_stats_table, policy->cpu); |
105 | if (!stat) | 105 | if (!stat) |
106 | return 0; | 106 | return 0; |
107 | cpufreq_stats_update(stat->cpu); | 107 | cpufreq_stats_update(stat->cpu); |
@@ -170,7 +170,7 @@ freq_table_get_index(struct cpufreq_stats *stat, unsigned int freq) | |||
170 | 170 | ||
171 | static void cpufreq_stats_free_table(unsigned int cpu) | 171 | static void cpufreq_stats_free_table(unsigned int cpu) |
172 | { | 172 | { |
173 | struct cpufreq_stats *stat = cpufreq_stats_table[cpu]; | 173 | struct cpufreq_stats *stat = per_cpu(cpufreq_stats_table, cpu); |
174 | struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); | 174 | struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); |
175 | if (policy && policy->cpu == cpu) | 175 | if (policy && policy->cpu == cpu) |
176 | sysfs_remove_group(&policy->kobj, &stats_attr_group); | 176 | sysfs_remove_group(&policy->kobj, &stats_attr_group); |
@@ -178,7 +178,7 @@ static void cpufreq_stats_free_table(unsigned int cpu) | |||
178 | kfree(stat->time_in_state); | 178 | kfree(stat->time_in_state); |
179 | kfree(stat); | 179 | kfree(stat); |
180 | } | 180 | } |
181 | cpufreq_stats_table[cpu] = NULL; | 181 | per_cpu(cpufreq_stats_table, cpu) = NULL; |
182 | if (policy) | 182 | if (policy) |
183 | cpufreq_cpu_put(policy); | 183 | cpufreq_cpu_put(policy); |
184 | } | 184 | } |
@@ -192,7 +192,7 @@ cpufreq_stats_create_table (struct cpufreq_policy *policy, | |||
192 | struct cpufreq_policy *data; | 192 | struct cpufreq_policy *data; |
193 | unsigned int alloc_size; | 193 | unsigned int alloc_size; |
194 | unsigned int cpu = policy->cpu; | 194 | unsigned int cpu = policy->cpu; |
195 | if (cpufreq_stats_table[cpu]) | 195 | if (per_cpu(cpufreq_stats_table, cpu)) |
196 | return -EBUSY; | 196 | return -EBUSY; |
197 | if ((stat = kzalloc(sizeof(struct cpufreq_stats), GFP_KERNEL)) == NULL) | 197 | if ((stat = kzalloc(sizeof(struct cpufreq_stats), GFP_KERNEL)) == NULL) |
198 | return -ENOMEM; | 198 | return -ENOMEM; |
@@ -207,7 +207,7 @@ cpufreq_stats_create_table (struct cpufreq_policy *policy, | |||
207 | goto error_out; | 207 | goto error_out; |
208 | 208 | ||
209 | stat->cpu = cpu; | 209 | stat->cpu = cpu; |
210 | cpufreq_stats_table[cpu] = stat; | 210 | per_cpu(cpufreq_stats_table, cpu) = stat; |
211 | 211 | ||
212 | for (i=0; table[i].frequency != CPUFREQ_TABLE_END; i++) { | 212 | for (i=0; table[i].frequency != CPUFREQ_TABLE_END; i++) { |
213 | unsigned int freq = table[i].frequency; | 213 | unsigned int freq = table[i].frequency; |
@@ -251,7 +251,7 @@ error_out: | |||
251 | cpufreq_cpu_put(data); | 251 | cpufreq_cpu_put(data); |
252 | error_get_fail: | 252 | error_get_fail: |
253 | kfree(stat); | 253 | kfree(stat); |
254 | cpufreq_stats_table[cpu] = NULL; | 254 | per_cpu(cpufreq_stats_table, cpu) = NULL; |
255 | return ret; | 255 | return ret; |
256 | } | 256 | } |
257 | 257 | ||
@@ -284,7 +284,7 @@ cpufreq_stat_notifier_trans (struct notifier_block *nb, unsigned long val, | |||
284 | if (val != CPUFREQ_POSTCHANGE) | 284 | if (val != CPUFREQ_POSTCHANGE) |
285 | return 0; | 285 | return 0; |
286 | 286 | ||
287 | stat = cpufreq_stats_table[freq->cpu]; | 287 | stat = per_cpu(cpufreq_stats_table, freq->cpu); |
288 | if (!stat) | 288 | if (!stat) |
289 | return 0; | 289 | return 0; |
290 | 290 | ||