aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/cpufreq/cpufreq_stats.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-07-21 18:10:37 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-07-21 18:10:37 -0400
commit6d52dcbe56ca8464bcad56d98a64bcd781596663 (patch)
tree607e1d2dee3998dad356d8c909189353a32aaa0e /drivers/cpufreq/cpufreq_stats.c
parenteb4225b2da2b9f3c1ee43efe58ed1415cc1d4c47 (diff)
parent48adcf148c83faa41999fb0b3524299c4e160fd9 (diff)
Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/davej/cpufreq
* 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/davej/cpufreq: [CPUFREQ] cpufreq: remove CVS keywords [CPUFREQ] change cpu freq arrays to per_cpu variables
Diffstat (limited to 'drivers/cpufreq/cpufreq_stats.c')
-rw-r--r--drivers/cpufreq/cpufreq_stats.c24
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
46static struct cpufreq_stats *cpufreq_stats_table[NR_CPUS]; 46static DEFINE_PER_CPU(struct cpufreq_stats *, cpufreq_stats_table);
47 47
48struct cpufreq_stats_attribute { 48struct 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)
71static ssize_t 71static ssize_t
72show_total_trans(struct cpufreq_policy *policy, char *buf) 72show_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
81static ssize_t 81static 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
171static void cpufreq_stats_free_table(unsigned int cpu) 171static 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);
252error_get_fail: 252error_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