Skip to content

Commit 6d52dcb

Browse files
committed
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
2 parents eb4225b + 48adcf1 commit 6d52dcb

File tree

5 files changed

+42
-43
lines changed

5 files changed

+42
-43
lines changed

arch/x86/kernel/cpu/cpufreq/powernow-k7.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/*
2-
* $Id: powernow-k7.h,v 1.2 2003/02/10 18:26:01 davej Exp $
32
* (C) 2003 Dave Jones.
43
*
54
* Licensed under the terms of the GNU GPL License version 2.

drivers/cpufreq/cpufreq.c

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@
3838
* also protects the cpufreq_cpu_data array.
3939
*/
4040
static struct cpufreq_driver *cpufreq_driver;
41-
static struct cpufreq_policy *cpufreq_cpu_data[NR_CPUS];
41+
static DEFINE_PER_CPU(struct cpufreq_policy *, cpufreq_cpu_data);
4242
#ifdef CONFIG_HOTPLUG_CPU
4343
/* This one keeps track of the previously set governor of a removed CPU */
44-
static struct cpufreq_governor *cpufreq_cpu_governor[NR_CPUS];
44+
static DEFINE_PER_CPU(struct cpufreq_governor *, cpufreq_cpu_governor);
4545
#endif
4646
static DEFINE_SPINLOCK(cpufreq_driver_lock);
4747

@@ -135,7 +135,7 @@ struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu)
135135
struct cpufreq_policy *data;
136136
unsigned long flags;
137137

138-
if (cpu >= NR_CPUS)
138+
if (cpu >= nr_cpu_ids)
139139
goto err_out;
140140

141141
/* get the cpufreq driver */
@@ -149,7 +149,7 @@ struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu)
149149

150150

151151
/* get the CPU */
152-
data = cpufreq_cpu_data[cpu];
152+
data = per_cpu(cpufreq_cpu_data, cpu);
153153

154154
if (!data)
155155
goto err_out_put_module;
@@ -327,7 +327,7 @@ void cpufreq_notify_transition(struct cpufreq_freqs *freqs, unsigned int state)
327327
dprintk("notification %u of frequency transition to %u kHz\n",
328328
state, freqs->new);
329329

330-
policy = cpufreq_cpu_data[freqs->cpu];
330+
policy = per_cpu(cpufreq_cpu_data, freqs->cpu);
331331
switch (state) {
332332

333333
case CPUFREQ_PRECHANGE:
@@ -828,8 +828,8 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
828828
#ifdef CONFIG_SMP
829829

830830
#ifdef CONFIG_HOTPLUG_CPU
831-
if (cpufreq_cpu_governor[cpu]){
832-
policy->governor = cpufreq_cpu_governor[cpu];
831+
if (per_cpu(cpufreq_cpu_governor, cpu)) {
832+
policy->governor = per_cpu(cpufreq_cpu_governor, cpu);
833833
dprintk("Restoring governor %s for cpu %d\n",
834834
policy->governor->name, cpu);
835835
}
@@ -854,7 +854,7 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
854854

855855
spin_lock_irqsave(&cpufreq_driver_lock, flags);
856856
managed_policy->cpus = policy->cpus;
857-
cpufreq_cpu_data[cpu] = managed_policy;
857+
per_cpu(cpufreq_cpu_data, cpu) = managed_policy;
858858
spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
859859

860860
dprintk("CPU already managed, adding link\n");
@@ -899,7 +899,7 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
899899

900900
spin_lock_irqsave(&cpufreq_driver_lock, flags);
901901
for_each_cpu_mask(j, policy->cpus) {
902-
cpufreq_cpu_data[j] = policy;
902+
per_cpu(cpufreq_cpu_data, j) = policy;
903903
per_cpu(policy_cpu, j) = policy->cpu;
904904
}
905905
spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
@@ -946,7 +946,7 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
946946
err_out_unregister:
947947
spin_lock_irqsave(&cpufreq_driver_lock, flags);
948948
for_each_cpu_mask(j, policy->cpus)
949-
cpufreq_cpu_data[j] = NULL;
949+
per_cpu(cpufreq_cpu_data, j) = NULL;
950950
spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
951951

952952
kobject_put(&policy->kobj);
@@ -989,15 +989,15 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev)
989989
dprintk("unregistering CPU %u\n", cpu);
990990

991991
spin_lock_irqsave(&cpufreq_driver_lock, flags);
992-
data = cpufreq_cpu_data[cpu];
992+
data = per_cpu(cpufreq_cpu_data, cpu);
993993

994994
if (!data) {
995995
spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
996996
cpufreq_debug_enable_ratelimit();
997997
unlock_policy_rwsem_write(cpu);
998998
return -EINVAL;
999999
}
1000-
cpufreq_cpu_data[cpu] = NULL;
1000+
per_cpu(cpufreq_cpu_data, cpu) = NULL;
10011001

10021002

10031003
#ifdef CONFIG_SMP
@@ -1019,19 +1019,19 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev)
10191019
#ifdef CONFIG_SMP
10201020

10211021
#ifdef CONFIG_HOTPLUG_CPU
1022-
cpufreq_cpu_governor[cpu] = data->governor;
1022+
per_cpu(cpufreq_cpu_governor, cpu) = data->governor;
10231023
#endif
10241024

10251025
/* if we have other CPUs still registered, we need to unlink them,
10261026
* or else wait_for_completion below will lock up. Clean the
1027-
* cpufreq_cpu_data[] while holding the lock, and remove the sysfs
1028-
* links afterwards.
1027+
* per_cpu(cpufreq_cpu_data) while holding the lock, and remove
1028+
* the sysfs links afterwards.
10291029
*/
10301030
if (unlikely(cpus_weight(data->cpus) > 1)) {
10311031
for_each_cpu_mask(j, data->cpus) {
10321032
if (j == cpu)
10331033
continue;
1034-
cpufreq_cpu_data[j] = NULL;
1034+
per_cpu(cpufreq_cpu_data, j) = NULL;
10351035
}
10361036
}
10371037

@@ -1043,7 +1043,7 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev)
10431043
continue;
10441044
dprintk("removing link for cpu %u\n", j);
10451045
#ifdef CONFIG_HOTPLUG_CPU
1046-
cpufreq_cpu_governor[j] = data->governor;
1046+
per_cpu(cpufreq_cpu_governor, j) = data->governor;
10471047
#endif
10481048
cpu_sys_dev = get_cpu_sysdev(j);
10491049
sysfs_remove_link(&cpu_sys_dev->kobj, "cpufreq");
@@ -1153,7 +1153,7 @@ EXPORT_SYMBOL(cpufreq_quick_get);
11531153

11541154
static unsigned int __cpufreq_get(unsigned int cpu)
11551155
{
1156-
struct cpufreq_policy *policy = cpufreq_cpu_data[cpu];
1156+
struct cpufreq_policy *policy = per_cpu(cpufreq_cpu_data, cpu);
11571157
unsigned int ret_freq = 0;
11581158

11591159
if (!cpufreq_driver->get)
@@ -1822,16 +1822,19 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
18221822
cpufreq_driver = driver_data;
18231823
spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
18241824

1825-
ret = sysdev_driver_register(&cpu_sysdev_class,&cpufreq_sysdev_driver);
1825+
ret = sysdev_driver_register(&cpu_sysdev_class,
1826+
&cpufreq_sysdev_driver);
18261827

18271828
if ((!ret) && !(cpufreq_driver->flags & CPUFREQ_STICKY)) {
18281829
int i;
18291830
ret = -ENODEV;
18301831

18311832
/* check for at least one working CPU */
1832-
for (i=0; i<NR_CPUS; i++)
1833-
if (cpufreq_cpu_data[i])
1833+
for (i = 0; i < nr_cpu_ids; i++)
1834+
if (cpu_possible(i) && per_cpu(cpufreq_cpu_data, i)) {
18341835
ret = 0;
1836+
break;
1837+
}
18351838

18361839
/* if all ->init() calls failed, unregister */
18371840
if (ret) {

drivers/cpufreq/cpufreq_stats.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ struct cpufreq_stats {
4343
#endif
4444
};
4545

46-
static struct cpufreq_stats *cpufreq_stats_table[NR_CPUS];
46+
static DEFINE_PER_CPU(struct cpufreq_stats *, cpufreq_stats_table);
4747

4848
struct cpufreq_stats_attribute {
4949
struct attribute attr;
@@ -58,7 +58,7 @@ cpufreq_stats_update (unsigned int cpu)
5858

5959
cur_time = get_jiffies_64();
6060
spin_lock(&cpufreq_stats_lock);
61-
stat = cpufreq_stats_table[cpu];
61+
stat = per_cpu(cpufreq_stats_table, cpu);
6262
if (stat->time_in_state)
6363
stat->time_in_state[stat->last_index] =
6464
cputime64_add(stat->time_in_state[stat->last_index],
@@ -71,19 +71,19 @@ cpufreq_stats_update (unsigned int cpu)
7171
static ssize_t
7272
show_total_trans(struct cpufreq_policy *policy, char *buf)
7373
{
74-
struct cpufreq_stats *stat = cpufreq_stats_table[policy->cpu];
74+
struct cpufreq_stats *stat = per_cpu(cpufreq_stats_table, policy->cpu);
7575
if (!stat)
7676
return 0;
7777
return sprintf(buf, "%d\n",
78-
cpufreq_stats_table[stat->cpu]->total_trans);
78+
per_cpu(cpufreq_stats_table, stat->cpu)->total_trans);
7979
}
8080

8181
static ssize_t
8282
show_time_in_state(struct cpufreq_policy *policy, char *buf)
8383
{
8484
ssize_t len = 0;
8585
int i;
86-
struct cpufreq_stats *stat = cpufreq_stats_table[policy->cpu];
86+
struct cpufreq_stats *stat = per_cpu(cpufreq_stats_table, policy->cpu);
8787
if (!stat)
8888
return 0;
8989
cpufreq_stats_update(stat->cpu);
@@ -101,7 +101,7 @@ show_trans_table(struct cpufreq_policy *policy, char *buf)
101101
ssize_t len = 0;
102102
int i, j;
103103

104-
struct cpufreq_stats *stat = cpufreq_stats_table[policy->cpu];
104+
struct cpufreq_stats *stat = per_cpu(cpufreq_stats_table, policy->cpu);
105105
if (!stat)
106106
return 0;
107107
cpufreq_stats_update(stat->cpu);
@@ -170,15 +170,15 @@ freq_table_get_index(struct cpufreq_stats *stat, unsigned int freq)
170170

171171
static void cpufreq_stats_free_table(unsigned int cpu)
172172
{
173-
struct cpufreq_stats *stat = cpufreq_stats_table[cpu];
173+
struct cpufreq_stats *stat = per_cpu(cpufreq_stats_table, cpu);
174174
struct cpufreq_policy *policy = cpufreq_cpu_get(cpu);
175175
if (policy && policy->cpu == cpu)
176176
sysfs_remove_group(&policy->kobj, &stats_attr_group);
177177
if (stat) {
178178
kfree(stat->time_in_state);
179179
kfree(stat);
180180
}
181-
cpufreq_stats_table[cpu] = NULL;
181+
per_cpu(cpufreq_stats_table, cpu) = NULL;
182182
if (policy)
183183
cpufreq_cpu_put(policy);
184184
}
@@ -192,7 +192,7 @@ cpufreq_stats_create_table (struct cpufreq_policy *policy,
192192
struct cpufreq_policy *data;
193193
unsigned int alloc_size;
194194
unsigned int cpu = policy->cpu;
195-
if (cpufreq_stats_table[cpu])
195+
if (per_cpu(cpufreq_stats_table, cpu))
196196
return -EBUSY;
197197
if ((stat = kzalloc(sizeof(struct cpufreq_stats), GFP_KERNEL)) == NULL)
198198
return -ENOMEM;
@@ -207,7 +207,7 @@ cpufreq_stats_create_table (struct cpufreq_policy *policy,
207207
goto error_out;
208208

209209
stat->cpu = cpu;
210-
cpufreq_stats_table[cpu] = stat;
210+
per_cpu(cpufreq_stats_table, cpu) = stat;
211211

212212
for (i=0; table[i].frequency != CPUFREQ_TABLE_END; i++) {
213213
unsigned int freq = table[i].frequency;
@@ -251,7 +251,7 @@ cpufreq_stats_create_table (struct cpufreq_policy *policy,
251251
cpufreq_cpu_put(data);
252252
error_get_fail:
253253
kfree(stat);
254-
cpufreq_stats_table[cpu] = NULL;
254+
per_cpu(cpufreq_stats_table, cpu) = NULL;
255255
return ret;
256256
}
257257

@@ -284,7 +284,7 @@ cpufreq_stat_notifier_trans (struct notifier_block *nb, unsigned long val,
284284
if (val != CPUFREQ_POSTCHANGE)
285285
return 0;
286286

287-
stat = cpufreq_stats_table[freq->cpu];
287+
stat = per_cpu(cpufreq_stats_table, freq->cpu);
288288
if (!stat)
289289
return 0;
290290

drivers/cpufreq/freq_table.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy,
174174
}
175175
EXPORT_SYMBOL_GPL(cpufreq_frequency_table_target);
176176

177-
static struct cpufreq_frequency_table *show_table[NR_CPUS];
177+
static DEFINE_PER_CPU(struct cpufreq_frequency_table *, show_table);
178178
/**
179179
* show_available_freqs - show available frequencies for the specified CPU
180180
*/
@@ -185,10 +185,10 @@ static ssize_t show_available_freqs (struct cpufreq_policy *policy, char *buf)
185185
ssize_t count = 0;
186186
struct cpufreq_frequency_table *table;
187187

188-
if (!show_table[cpu])
188+
if (!per_cpu(show_table, cpu))
189189
return -ENODEV;
190190

191-
table = show_table[cpu];
191+
table = per_cpu(show_table, cpu);
192192

193193
for (i=0; (table[i].frequency != CPUFREQ_TABLE_END); i++) {
194194
if (table[i].frequency == CPUFREQ_ENTRY_INVALID)
@@ -217,20 +217,20 @@ void cpufreq_frequency_table_get_attr(struct cpufreq_frequency_table *table,
217217
unsigned int cpu)
218218
{
219219
dprintk("setting show_table for cpu %u to %p\n", cpu, table);
220-
show_table[cpu] = table;
220+
per_cpu(show_table, cpu) = table;
221221
}
222222
EXPORT_SYMBOL_GPL(cpufreq_frequency_table_get_attr);
223223

224224
void cpufreq_frequency_table_put_attr(unsigned int cpu)
225225
{
226226
dprintk("clearing show_table for cpu %u\n", cpu);
227-
show_table[cpu] = NULL;
227+
per_cpu(show_table, cpu) = NULL;
228228
}
229229
EXPORT_SYMBOL_GPL(cpufreq_frequency_table_put_attr);
230230

231231
struct cpufreq_frequency_table *cpufreq_frequency_get_table(unsigned int cpu)
232232
{
233-
return show_table[cpu];
233+
return per_cpu(show_table, cpu);
234234
}
235235
EXPORT_SYMBOL_GPL(cpufreq_frequency_get_table);
236236

include/linux/cpufreq.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
* Copyright (C) 2001 Russell King
55
* (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de>
66
*
7-
*
8-
* $Id: cpufreq.h,v 1.36 2003/01/20 17:31:48 db Exp $
9-
*
107
* This program is free software; you can redistribute it and/or modify
118
* it under the terms of the GNU General Public License version 2 as
129
* published by the Free Software Foundation.

0 commit comments

Comments
 (0)