Skip to content

Commit 5070158

Browse files
vireshkrafaeljw
authored andcommitted
cpufreq: rename index as driver_data in cpufreq_frequency_table
The "index" field of struct cpufreq_frequency_table was never an index and isn't used at all by the cpufreq core. It only is useful for cpufreq drivers for their internal purposes. Many people nowadays blindly set it in ascending order with the assumption that the core will use it, which is a mistake. Rename it to "driver_data" as that's what its purpose is. All of its users are updated accordingly. [rjw: Changelog] Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Acked-by: Simon Horman <horms+renesas@verge.net.au> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 2361be2 commit 5070158

37 files changed

Lines changed: 223 additions & 227 deletions

‎Documentation/cpu-freq/cpu-drivers.txt‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ As most cpufreq processors only allow for being set to a few specific
186186
frequencies, a "frequency table" with some functions might assist in
187187
some work of the processor driver. Such a "frequency table" consists
188188
of an array of struct cpufreq_frequency_table entries, with any value in
189-
"index" you want to use, and the corresponding frequency in
189+
"driver_data" you want to use, and the corresponding frequency in
190190
"frequency". At the end of the table, you need to add a
191191
cpufreq_frequency_table entry with frequency set to CPUFREQ_TABLE_END. And
192192
if you want to skip one entry in the table, set the frequency to
@@ -214,10 +214,4 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy,
214214
is the corresponding frequency table helper for the ->target
215215
stage. Just pass the values to this function, and the unsigned int
216216
index returns the number of the frequency table entry which contains
217-
the frequency the CPU shall be set to. PLEASE NOTE: This is not the
218-
"index" which is in this cpufreq_table_entry.index, but instead
219-
cpufreq_table[index]. So, the new frequency is
220-
cpufreq_table[index].frequency, and the value you stored into the
221-
frequency table "index" field is
222-
cpufreq_table[index].index.
223-
217+
the frequency the CPU shall be set to.

‎arch/arm/mach-davinci/da850.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,7 +1004,7 @@ static const struct da850_opp da850_opp_96 = {
10041004

10051005
#define OPP(freq) \
10061006
{ \
1007-
.index = (unsigned int) &da850_opp_##freq, \
1007+
.driver_data = (unsigned int) &da850_opp_##freq, \
10081008
.frequency = freq * 1000, \
10091009
}
10101010

@@ -1016,7 +1016,7 @@ static struct cpufreq_frequency_table da850_freq_table[] = {
10161016
OPP(200),
10171017
OPP(96),
10181018
{
1019-
.index = 0,
1019+
.driver_data = 0,
10201020
.frequency = CPUFREQ_TABLE_END,
10211021
},
10221022
};
@@ -1044,7 +1044,7 @@ static int da850_set_voltage(unsigned int index)
10441044
if (!cvdd)
10451045
return -ENODEV;
10461046

1047-
opp = (struct da850_opp *) cpufreq_info.freq_table[index].index;
1047+
opp = (struct da850_opp *) cpufreq_info.freq_table[index].driver_data;
10481048

10491049
return regulator_set_voltage(cvdd, opp->cvdd_min, opp->cvdd_max);
10501050
}
@@ -1125,7 +1125,7 @@ static int da850_set_pll0rate(struct clk *clk, unsigned long index)
11251125
struct pll_data *pll = clk->pll_data;
11261126
int ret;
11271127

1128-
opp = (struct da850_opp *) cpufreq_info.freq_table[index].index;
1128+
opp = (struct da850_opp *) cpufreq_info.freq_table[index].driver_data;
11291129
prediv = opp->prediv;
11301130
mult = opp->mult;
11311131
postdiv = opp->postdiv;

‎arch/arm/mach-s3c24xx/cpufreq-utils.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,5 @@ void s3c2410_cpufreq_setrefresh(struct s3c_cpufreq_config *cfg)
6060
*/
6161
void s3c2410_set_fvco(struct s3c_cpufreq_config *cfg)
6262
{
63-
__raw_writel(cfg->pll.index, S3C2410_MPLLCON);
63+
__raw_writel(cfg->pll.driver_data, S3C2410_MPLLCON);
6464
}

‎arch/arm/mach-s3c24xx/cpufreq.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ static void s3c_cpufreq_getcur(struct s3c_cpufreq_config *cfg)
7070
cfg->freq.pclk = pclk = clk_get_rate(clk_pclk);
7171
cfg->freq.armclk = armclk = clk_get_rate(clk_arm);
7272

73-
cfg->pll.index = __raw_readl(S3C2410_MPLLCON);
73+
cfg->pll.driver_data = __raw_readl(S3C2410_MPLLCON);
7474
cfg->pll.frequency = fclk;
7575

7676
cfg->freq.hclk_tns = 1000000000 / (cfg->freq.hclk / 10);
@@ -431,7 +431,7 @@ static unsigned int suspend_freq;
431431
static int s3c_cpufreq_suspend(struct cpufreq_policy *policy)
432432
{
433433
suspend_pll.frequency = clk_get_rate(_clk_mpll);
434-
suspend_pll.index = __raw_readl(S3C2410_MPLLCON);
434+
suspend_pll.driver_data = __raw_readl(S3C2410_MPLLCON);
435435
suspend_freq = s3c_cpufreq_get(0) * 1000;
436436

437437
return 0;

‎arch/arm/mach-s3c24xx/pll-s3c2410.c‎

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -33,36 +33,36 @@
3333
#include <plat/cpu-freq-core.h>
3434

3535
static struct cpufreq_frequency_table pll_vals_12MHz[] = {
36-
{ .frequency = 34000000, .index = PLLVAL(82, 2, 3), },
37-
{ .frequency = 45000000, .index = PLLVAL(82, 1, 3), },
38-
{ .frequency = 51000000, .index = PLLVAL(161, 3, 3), },
39-
{ .frequency = 48000000, .index = PLLVAL(120, 2, 3), },
40-
{ .frequency = 56000000, .index = PLLVAL(142, 2, 3), },
41-
{ .frequency = 68000000, .index = PLLVAL(82, 2, 2), },
42-
{ .frequency = 79000000, .index = PLLVAL(71, 1, 2), },
43-
{ .frequency = 85000000, .index = PLLVAL(105, 2, 2), },
44-
{ .frequency = 90000000, .index = PLLVAL(112, 2, 2), },
45-
{ .frequency = 101000000, .index = PLLVAL(127, 2, 2), },
46-
{ .frequency = 113000000, .index = PLLVAL(105, 1, 2), },
47-
{ .frequency = 118000000, .index = PLLVAL(150, 2, 2), },
48-
{ .frequency = 124000000, .index = PLLVAL(116, 1, 2), },
49-
{ .frequency = 135000000, .index = PLLVAL(82, 2, 1), },
50-
{ .frequency = 147000000, .index = PLLVAL(90, 2, 1), },
51-
{ .frequency = 152000000, .index = PLLVAL(68, 1, 1), },
52-
{ .frequency = 158000000, .index = PLLVAL(71, 1, 1), },
53-
{ .frequency = 170000000, .index = PLLVAL(77, 1, 1), },
54-
{ .frequency = 180000000, .index = PLLVAL(82, 1, 1), },
55-
{ .frequency = 186000000, .index = PLLVAL(85, 1, 1), },
56-
{ .frequency = 192000000, .index = PLLVAL(88, 1, 1), },
57-
{ .frequency = 203000000, .index = PLLVAL(161, 3, 1), },
36+
{ .frequency = 34000000, .driver_data = PLLVAL(82, 2, 3), },
37+
{ .frequency = 45000000, .driver_data = PLLVAL(82, 1, 3), },
38+
{ .frequency = 51000000, .driver_data = PLLVAL(161, 3, 3), },
39+
{ .frequency = 48000000, .driver_data = PLLVAL(120, 2, 3), },
40+
{ .frequency = 56000000, .driver_data = PLLVAL(142, 2, 3), },
41+
{ .frequency = 68000000, .driver_data = PLLVAL(82, 2, 2), },
42+
{ .frequency = 79000000, .driver_data = PLLVAL(71, 1, 2), },
43+
{ .frequency = 85000000, .driver_data = PLLVAL(105, 2, 2), },
44+
{ .frequency = 90000000, .driver_data = PLLVAL(112, 2, 2), },
45+
{ .frequency = 101000000, .driver_data = PLLVAL(127, 2, 2), },
46+
{ .frequency = 113000000, .driver_data = PLLVAL(105, 1, 2), },
47+
{ .frequency = 118000000, .driver_data = PLLVAL(150, 2, 2), },
48+
{ .frequency = 124000000, .driver_data = PLLVAL(116, 1, 2), },
49+
{ .frequency = 135000000, .driver_data = PLLVAL(82, 2, 1), },
50+
{ .frequency = 147000000, .driver_data = PLLVAL(90, 2, 1), },
51+
{ .frequency = 152000000, .driver_data = PLLVAL(68, 1, 1), },
52+
{ .frequency = 158000000, .driver_data = PLLVAL(71, 1, 1), },
53+
{ .frequency = 170000000, .driver_data = PLLVAL(77, 1, 1), },
54+
{ .frequency = 180000000, .driver_data = PLLVAL(82, 1, 1), },
55+
{ .frequency = 186000000, .driver_data = PLLVAL(85, 1, 1), },
56+
{ .frequency = 192000000, .driver_data = PLLVAL(88, 1, 1), },
57+
{ .frequency = 203000000, .driver_data = PLLVAL(161, 3, 1), },
5858

5959
/* 2410A extras */
6060

61-
{ .frequency = 210000000, .index = PLLVAL(132, 2, 1), },
62-
{ .frequency = 226000000, .index = PLLVAL(105, 1, 1), },
63-
{ .frequency = 266000000, .index = PLLVAL(125, 1, 1), },
64-
{ .frequency = 268000000, .index = PLLVAL(126, 1, 1), },
65-
{ .frequency = 270000000, .index = PLLVAL(127, 1, 1), },
61+
{ .frequency = 210000000, .driver_data = PLLVAL(132, 2, 1), },
62+
{ .frequency = 226000000, .driver_data = PLLVAL(105, 1, 1), },
63+
{ .frequency = 266000000, .driver_data = PLLVAL(125, 1, 1), },
64+
{ .frequency = 268000000, .driver_data = PLLVAL(126, 1, 1), },
65+
{ .frequency = 270000000, .driver_data = PLLVAL(127, 1, 1), },
6666
};
6767

6868
static int s3c2410_plls_add(struct device *dev, struct subsys_interface *sif)

‎arch/arm/mach-s3c24xx/pll-s3c2440-12000000.c‎

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -21,33 +21,33 @@
2121
#include <plat/cpu-freq-core.h>
2222

2323
static struct cpufreq_frequency_table s3c2440_plls_12[] __initdata = {
24-
{ .frequency = 75000000, .index = PLLVAL(0x75, 3, 3), }, /* FVco 600.000000 */
25-
{ .frequency = 80000000, .index = PLLVAL(0x98, 4, 3), }, /* FVco 640.000000 */
26-
{ .frequency = 90000000, .index = PLLVAL(0x70, 2, 3), }, /* FVco 720.000000 */
27-
{ .frequency = 100000000, .index = PLLVAL(0x5c, 1, 3), }, /* FVco 800.000000 */
28-
{ .frequency = 110000000, .index = PLLVAL(0x66, 1, 3), }, /* FVco 880.000000 */
29-
{ .frequency = 120000000, .index = PLLVAL(0x70, 1, 3), }, /* FVco 960.000000 */
30-
{ .frequency = 150000000, .index = PLLVAL(0x75, 3, 2), }, /* FVco 600.000000 */
31-
{ .frequency = 160000000, .index = PLLVAL(0x98, 4, 2), }, /* FVco 640.000000 */
32-
{ .frequency = 170000000, .index = PLLVAL(0x4d, 1, 2), }, /* FVco 680.000000 */
33-
{ .frequency = 180000000, .index = PLLVAL(0x70, 2, 2), }, /* FVco 720.000000 */
34-
{ .frequency = 190000000, .index = PLLVAL(0x57, 1, 2), }, /* FVco 760.000000 */
35-
{ .frequency = 200000000, .index = PLLVAL(0x5c, 1, 2), }, /* FVco 800.000000 */
36-
{ .frequency = 210000000, .index = PLLVAL(0x84, 2, 2), }, /* FVco 840.000000 */
37-
{ .frequency = 220000000, .index = PLLVAL(0x66, 1, 2), }, /* FVco 880.000000 */
38-
{ .frequency = 230000000, .index = PLLVAL(0x6b, 1, 2), }, /* FVco 920.000000 */
39-
{ .frequency = 240000000, .index = PLLVAL(0x70, 1, 2), }, /* FVco 960.000000 */
40-
{ .frequency = 300000000, .index = PLLVAL(0x75, 3, 1), }, /* FVco 600.000000 */
41-
{ .frequency = 310000000, .index = PLLVAL(0x93, 4, 1), }, /* FVco 620.000000 */
42-
{ .frequency = 320000000, .index = PLLVAL(0x98, 4, 1), }, /* FVco 640.000000 */
43-
{ .frequency = 330000000, .index = PLLVAL(0x66, 2, 1), }, /* FVco 660.000000 */
44-
{ .frequency = 340000000, .index = PLLVAL(0x4d, 1, 1), }, /* FVco 680.000000 */
45-
{ .frequency = 350000000, .index = PLLVAL(0xa7, 4, 1), }, /* FVco 700.000000 */
46-
{ .frequency = 360000000, .index = PLLVAL(0x70, 2, 1), }, /* FVco 720.000000 */
47-
{ .frequency = 370000000, .index = PLLVAL(0xb1, 4, 1), }, /* FVco 740.000000 */
48-
{ .frequency = 380000000, .index = PLLVAL(0x57, 1, 1), }, /* FVco 760.000000 */
49-
{ .frequency = 390000000, .index = PLLVAL(0x7a, 2, 1), }, /* FVco 780.000000 */
50-
{ .frequency = 400000000, .index = PLLVAL(0x5c, 1, 1), }, /* FVco 800.000000 */
24+
{ .frequency = 75000000, .driver_data = PLLVAL(0x75, 3, 3), }, /* FVco 600.000000 */
25+
{ .frequency = 80000000, .driver_data = PLLVAL(0x98, 4, 3), }, /* FVco 640.000000 */
26+
{ .frequency = 90000000, .driver_data = PLLVAL(0x70, 2, 3), }, /* FVco 720.000000 */
27+
{ .frequency = 100000000, .driver_data = PLLVAL(0x5c, 1, 3), }, /* FVco 800.000000 */
28+
{ .frequency = 110000000, .driver_data = PLLVAL(0x66, 1, 3), }, /* FVco 880.000000 */
29+
{ .frequency = 120000000, .driver_data = PLLVAL(0x70, 1, 3), }, /* FVco 960.000000 */
30+
{ .frequency = 150000000, .driver_data = PLLVAL(0x75, 3, 2), }, /* FVco 600.000000 */
31+
{ .frequency = 160000000, .driver_data = PLLVAL(0x98, 4, 2), }, /* FVco 640.000000 */
32+
{ .frequency = 170000000, .driver_data = PLLVAL(0x4d, 1, 2), }, /* FVco 680.000000 */
33+
{ .frequency = 180000000, .driver_data = PLLVAL(0x70, 2, 2), }, /* FVco 720.000000 */
34+
{ .frequency = 190000000, .driver_data = PLLVAL(0x57, 1, 2), }, /* FVco 760.000000 */
35+
{ .frequency = 200000000, .driver_data = PLLVAL(0x5c, 1, 2), }, /* FVco 800.000000 */
36+
{ .frequency = 210000000, .driver_data = PLLVAL(0x84, 2, 2), }, /* FVco 840.000000 */
37+
{ .frequency = 220000000, .driver_data = PLLVAL(0x66, 1, 2), }, /* FVco 880.000000 */
38+
{ .frequency = 230000000, .driver_data = PLLVAL(0x6b, 1, 2), }, /* FVco 920.000000 */
39+
{ .frequency = 240000000, .driver_data = PLLVAL(0x70, 1, 2), }, /* FVco 960.000000 */
40+
{ .frequency = 300000000, .driver_data = PLLVAL(0x75, 3, 1), }, /* FVco 600.000000 */
41+
{ .frequency = 310000000, .driver_data = PLLVAL(0x93, 4, 1), }, /* FVco 620.000000 */
42+
{ .frequency = 320000000, .driver_data = PLLVAL(0x98, 4, 1), }, /* FVco 640.000000 */
43+
{ .frequency = 330000000, .driver_data = PLLVAL(0x66, 2, 1), }, /* FVco 660.000000 */
44+
{ .frequency = 340000000, .driver_data = PLLVAL(0x4d, 1, 1), }, /* FVco 680.000000 */
45+
{ .frequency = 350000000, .driver_data = PLLVAL(0xa7, 4, 1), }, /* FVco 700.000000 */
46+
{ .frequency = 360000000, .driver_data = PLLVAL(0x70, 2, 1), }, /* FVco 720.000000 */
47+
{ .frequency = 370000000, .driver_data = PLLVAL(0xb1, 4, 1), }, /* FVco 740.000000 */
48+
{ .frequency = 380000000, .driver_data = PLLVAL(0x57, 1, 1), }, /* FVco 760.000000 */
49+
{ .frequency = 390000000, .driver_data = PLLVAL(0x7a, 2, 1), }, /* FVco 780.000000 */
50+
{ .frequency = 400000000, .driver_data = PLLVAL(0x5c, 1, 1), }, /* FVco 800.000000 */
5151
};
5252

5353
static int s3c2440_plls12_add(struct device *dev, struct subsys_interface *sif)

0 commit comments

Comments
 (0)