diff options
Diffstat (limited to 'drivers/cpufreq')
60 files changed, 561 insertions, 737 deletions
diff --git a/drivers/cpufreq/Kconfig.arm b/drivers/cpufreq/Kconfig.arm index de4d5d93c3fd..0fa204b244bd 100644 --- a/drivers/cpufreq/Kconfig.arm +++ b/drivers/cpufreq/Kconfig.arm | |||
@@ -17,37 +17,47 @@ config ARM_DT_BL_CPUFREQ | |||
17 | big.LITTLE platform. This gets frequency tables from DT. | 17 | big.LITTLE platform. This gets frequency tables from DT. |
18 | 18 | ||
19 | config ARM_EXYNOS_CPUFREQ | 19 | config ARM_EXYNOS_CPUFREQ |
20 | bool "SAMSUNG EXYNOS SoCs" | 20 | bool |
21 | depends on ARCH_EXYNOS | ||
22 | select CPU_FREQ_TABLE | 21 | select CPU_FREQ_TABLE |
23 | default y | ||
24 | help | ||
25 | This adds the CPUFreq driver common part for Samsung | ||
26 | EXYNOS SoCs. | ||
27 | |||
28 | If in doubt, say N. | ||
29 | 22 | ||
30 | config ARM_EXYNOS4210_CPUFREQ | 23 | config ARM_EXYNOS4210_CPUFREQ |
31 | def_bool CPU_EXYNOS4210 | 24 | bool "SAMSUNG EXYNOS4210" |
25 | depends on CPU_EXYNOS4210 | ||
26 | default y | ||
27 | select ARM_EXYNOS_CPUFREQ | ||
32 | help | 28 | help |
33 | This adds the CPUFreq driver for Samsung EXYNOS4210 | 29 | This adds the CPUFreq driver for Samsung EXYNOS4210 |
34 | SoC (S5PV310 or S5PC210). | 30 | SoC (S5PV310 or S5PC210). |
35 | 31 | ||
32 | If in doubt, say N. | ||
33 | |||
36 | config ARM_EXYNOS4X12_CPUFREQ | 34 | config ARM_EXYNOS4X12_CPUFREQ |
37 | def_bool (SOC_EXYNOS4212 || SOC_EXYNOS4412) | 35 | bool "SAMSUNG EXYNOS4x12" |
36 | depends on (SOC_EXYNOS4212 || SOC_EXYNOS4412) | ||
37 | default y | ||
38 | select ARM_EXYNOS_CPUFREQ | ||
38 | help | 39 | help |
39 | This adds the CPUFreq driver for Samsung EXYNOS4X12 | 40 | This adds the CPUFreq driver for Samsung EXYNOS4X12 |
40 | SoC (EXYNOS4212 or EXYNOS4412). | 41 | SoC (EXYNOS4212 or EXYNOS4412). |
41 | 42 | ||
43 | If in doubt, say N. | ||
44 | |||
42 | config ARM_EXYNOS5250_CPUFREQ | 45 | config ARM_EXYNOS5250_CPUFREQ |
43 | def_bool SOC_EXYNOS5250 | 46 | bool "SAMSUNG EXYNOS5250" |
47 | depends on SOC_EXYNOS5250 | ||
48 | default y | ||
49 | select ARM_EXYNOS_CPUFREQ | ||
44 | help | 50 | help |
45 | This adds the CPUFreq driver for Samsung EXYNOS5250 | 51 | This adds the CPUFreq driver for Samsung EXYNOS5250 |
46 | SoC. | 52 | SoC. |
47 | 53 | ||
54 | If in doubt, say N. | ||
55 | |||
48 | config ARM_EXYNOS5440_CPUFREQ | 56 | config ARM_EXYNOS5440_CPUFREQ |
49 | def_bool SOC_EXYNOS5440 | 57 | bool "SAMSUNG EXYNOS5440" |
58 | depends on SOC_EXYNOS5440 | ||
50 | depends on HAVE_CLK && PM_OPP && OF | 59 | depends on HAVE_CLK && PM_OPP && OF |
60 | default y | ||
51 | select CPU_FREQ_TABLE | 61 | select CPU_FREQ_TABLE |
52 | help | 62 | help |
53 | This adds the CPUFreq driver for Samsung EXYNOS5440 | 63 | This adds the CPUFreq driver for Samsung EXYNOS5440 |
@@ -55,6 +65,8 @@ config ARM_EXYNOS5440_CPUFREQ | |||
55 | different than previous exynos controllers so not using | 65 | different than previous exynos controllers so not using |
56 | the common exynos framework. | 66 | the common exynos framework. |
57 | 67 | ||
68 | If in doubt, say N. | ||
69 | |||
58 | config ARM_HIGHBANK_CPUFREQ | 70 | config ARM_HIGHBANK_CPUFREQ |
59 | tristate "Calxeda Highbank-based" | 71 | tristate "Calxeda Highbank-based" |
60 | depends on ARCH_HIGHBANK | 72 | depends on ARCH_HIGHBANK |
diff --git a/drivers/cpufreq/Makefile b/drivers/cpufreq/Makefile index d345b5a7aa71..ad5866c2ada0 100644 --- a/drivers/cpufreq/Makefile +++ b/drivers/cpufreq/Makefile | |||
@@ -23,7 +23,7 @@ obj-$(CONFIG_GENERIC_CPUFREQ_CPU0) += cpufreq-cpu0.o | |||
23 | # powernow-k8 can load then. ACPI is preferred to all other hardware-specific drivers. | 23 | # powernow-k8 can load then. ACPI is preferred to all other hardware-specific drivers. |
24 | # speedstep-* is preferred over p4-clockmod. | 24 | # speedstep-* is preferred over p4-clockmod. |
25 | 25 | ||
26 | obj-$(CONFIG_X86_ACPI_CPUFREQ) += acpi-cpufreq.o mperf.o | 26 | obj-$(CONFIG_X86_ACPI_CPUFREQ) += acpi-cpufreq.o |
27 | obj-$(CONFIG_X86_POWERNOW_K8) += powernow-k8.o | 27 | obj-$(CONFIG_X86_POWERNOW_K8) += powernow-k8.o |
28 | obj-$(CONFIG_X86_PCC_CPUFREQ) += pcc-cpufreq.o | 28 | obj-$(CONFIG_X86_PCC_CPUFREQ) += pcc-cpufreq.o |
29 | obj-$(CONFIG_X86_POWERNOW_K6) += powernow-k6.o | 29 | obj-$(CONFIG_X86_POWERNOW_K6) += powernow-k6.o |
diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c index 39264020b88a..a1260b4549db 100644 --- a/drivers/cpufreq/acpi-cpufreq.c +++ b/drivers/cpufreq/acpi-cpufreq.c | |||
@@ -45,7 +45,6 @@ | |||
45 | #include <asm/msr.h> | 45 | #include <asm/msr.h> |
46 | #include <asm/processor.h> | 46 | #include <asm/processor.h> |
47 | #include <asm/cpufeature.h> | 47 | #include <asm/cpufeature.h> |
48 | #include "mperf.h" | ||
49 | 48 | ||
50 | MODULE_AUTHOR("Paul Diefenbaugh, Dominik Brodowski"); | 49 | MODULE_AUTHOR("Paul Diefenbaugh, Dominik Brodowski"); |
51 | MODULE_DESCRIPTION("ACPI Processor P-States Driver"); | 50 | MODULE_DESCRIPTION("ACPI Processor P-States Driver"); |
@@ -198,7 +197,7 @@ static ssize_t show_cpb(struct cpufreq_policy *policy, char *buf) | |||
198 | return sprintf(buf, "%u\n", boost_enabled); | 197 | return sprintf(buf, "%u\n", boost_enabled); |
199 | } | 198 | } |
200 | 199 | ||
201 | static struct freq_attr cpb = __ATTR(cpb, 0644, show_cpb, store_cpb); | 200 | cpufreq_freq_attr_rw(cpb); |
202 | #endif | 201 | #endif |
203 | 202 | ||
204 | static int check_est_cpu(unsigned int cpuid) | 203 | static int check_est_cpu(unsigned int cpuid) |
@@ -710,7 +709,7 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy) | |||
710 | return blacklisted; | 709 | return blacklisted; |
711 | #endif | 710 | #endif |
712 | 711 | ||
713 | data = kzalloc(sizeof(struct acpi_cpufreq_data), GFP_KERNEL); | 712 | data = kzalloc(sizeof(*data), GFP_KERNEL); |
714 | if (!data) | 713 | if (!data) |
715 | return -ENOMEM; | 714 | return -ENOMEM; |
716 | 715 | ||
@@ -800,7 +799,7 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy) | |||
800 | goto err_unreg; | 799 | goto err_unreg; |
801 | } | 800 | } |
802 | 801 | ||
803 | data->freq_table = kmalloc(sizeof(struct cpufreq_frequency_table) * | 802 | data->freq_table = kmalloc(sizeof(*data->freq_table) * |
804 | (perf->state_count+1), GFP_KERNEL); | 803 | (perf->state_count+1), GFP_KERNEL); |
805 | if (!data->freq_table) { | 804 | if (!data->freq_table) { |
806 | result = -ENOMEM; | 805 | result = -ENOMEM; |
@@ -861,10 +860,6 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy) | |||
861 | /* notify BIOS that we exist */ | 860 | /* notify BIOS that we exist */ |
862 | acpi_processor_notify_smm(THIS_MODULE); | 861 | acpi_processor_notify_smm(THIS_MODULE); |
863 | 862 | ||
864 | /* Check for APERF/MPERF support in hardware */ | ||
865 | if (boot_cpu_has(X86_FEATURE_APERFMPERF)) | ||
866 | acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf; | ||
867 | |||
868 | pr_debug("CPU%u - ACPI performance management activated.\n", cpu); | 863 | pr_debug("CPU%u - ACPI performance management activated.\n", cpu); |
869 | for (i = 0; i < perf->state_count; i++) | 864 | for (i = 0; i < perf->state_count; i++) |
870 | pr_debug(" %cP%d: %d MHz, %d mW, %d uS\n", | 865 | pr_debug(" %cP%d: %d MHz, %d mW, %d uS\n", |
@@ -941,7 +936,6 @@ static struct cpufreq_driver acpi_cpufreq_driver = { | |||
941 | .exit = acpi_cpufreq_cpu_exit, | 936 | .exit = acpi_cpufreq_cpu_exit, |
942 | .resume = acpi_cpufreq_resume, | 937 | .resume = acpi_cpufreq_resume, |
943 | .name = "acpi-cpufreq", | 938 | .name = "acpi-cpufreq", |
944 | .owner = THIS_MODULE, | ||
945 | .attr = acpi_cpufreq_attr, | 939 | .attr = acpi_cpufreq_attr, |
946 | }; | 940 | }; |
947 | 941 | ||
diff --git a/drivers/cpufreq/arm_big_little_dt.c b/drivers/cpufreq/arm_big_little_dt.c index fd9e3ea6a480..480c0bd0468d 100644 --- a/drivers/cpufreq/arm_big_little_dt.c +++ b/drivers/cpufreq/arm_big_little_dt.c | |||
@@ -19,12 +19,11 @@ | |||
19 | 19 | ||
20 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | 20 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
21 | 21 | ||
22 | #include <linux/cpu.h> | ||
23 | #include <linux/cpufreq.h> | 22 | #include <linux/cpufreq.h> |
24 | #include <linux/device.h> | 23 | #include <linux/device.h> |
25 | #include <linux/export.h> | 24 | #include <linux/export.h> |
26 | #include <linux/module.h> | 25 | #include <linux/module.h> |
27 | #include <linux/of.h> | 26 | #include <linux/of_device.h> |
28 | #include <linux/opp.h> | 27 | #include <linux/opp.h> |
29 | #include <linux/platform_device.h> | 28 | #include <linux/platform_device.h> |
30 | #include <linux/slab.h> | 29 | #include <linux/slab.h> |
@@ -34,27 +33,13 @@ | |||
34 | /* get cpu node with valid operating-points */ | 33 | /* get cpu node with valid operating-points */ |
35 | static struct device_node *get_cpu_node_with_valid_op(int cpu) | 34 | static struct device_node *get_cpu_node_with_valid_op(int cpu) |
36 | { | 35 | { |
37 | struct device_node *np = NULL, *parent; | 36 | struct device_node *np = of_cpu_device_node_get(cpu); |
38 | int count = 0; | ||
39 | 37 | ||
40 | parent = of_find_node_by_path("/cpus"); | 38 | if (!of_get_property(np, "operating-points", NULL)) { |
41 | if (!parent) { | 39 | of_node_put(np); |
42 | pr_err("failed to find OF /cpus\n"); | 40 | np = NULL; |
43 | return NULL; | ||
44 | } | 41 | } |
45 | 42 | ||
46 | for_each_child_of_node(parent, np) { | ||
47 | if (count++ != cpu) | ||
48 | continue; | ||
49 | if (!of_get_property(np, "operating-points", NULL)) { | ||
50 | of_node_put(np); | ||
51 | np = NULL; | ||
52 | } | ||
53 | |||
54 | break; | ||
55 | } | ||
56 | |||
57 | of_node_put(parent); | ||
58 | return np; | 43 | return np; |
59 | } | 44 | } |
60 | 45 | ||
@@ -63,11 +48,12 @@ static int dt_init_opp_table(struct device *cpu_dev) | |||
63 | struct device_node *np; | 48 | struct device_node *np; |
64 | int ret; | 49 | int ret; |
65 | 50 | ||
66 | np = get_cpu_node_with_valid_op(cpu_dev->id); | 51 | np = of_node_get(cpu_dev->of_node); |
67 | if (!np) | 52 | if (!np) { |
68 | return -ENODATA; | 53 | pr_err("failed to find cpu%d node\n", cpu_dev->id); |
54 | return -ENOENT; | ||
55 | } | ||
69 | 56 | ||
70 | cpu_dev->of_node = np; | ||
71 | ret = of_init_opp_table(cpu_dev); | 57 | ret = of_init_opp_table(cpu_dev); |
72 | of_node_put(np); | 58 | of_node_put(np); |
73 | 59 | ||
@@ -79,9 +65,11 @@ static int dt_get_transition_latency(struct device *cpu_dev) | |||
79 | struct device_node *np; | 65 | struct device_node *np; |
80 | u32 transition_latency = CPUFREQ_ETERNAL; | 66 | u32 transition_latency = CPUFREQ_ETERNAL; |
81 | 67 | ||
82 | np = get_cpu_node_with_valid_op(cpu_dev->id); | 68 | np = of_node_get(cpu_dev->of_node); |
83 | if (!np) | 69 | if (!np) { |
70 | pr_info("Failed to find cpu node. Use CPUFREQ_ETERNAL transition latency\n"); | ||
84 | return CPUFREQ_ETERNAL; | 71 | return CPUFREQ_ETERNAL; |
72 | } | ||
85 | 73 | ||
86 | of_property_read_u32(np, "clock-latency", &transition_latency); | 74 | of_property_read_u32(np, "clock-latency", &transition_latency); |
87 | of_node_put(np); | 75 | of_node_put(np); |
diff --git a/drivers/cpufreq/at32ap-cpufreq.c b/drivers/cpufreq/at32ap-cpufreq.c index 654488723cb5..e0c38d938997 100644 --- a/drivers/cpufreq/at32ap-cpufreq.c +++ b/drivers/cpufreq/at32ap-cpufreq.c | |||
@@ -108,7 +108,6 @@ static int __init at32_cpufreq_driver_init(struct cpufreq_policy *policy) | |||
108 | 108 | ||
109 | static struct cpufreq_driver at32_driver = { | 109 | static struct cpufreq_driver at32_driver = { |
110 | .name = "at32ap", | 110 | .name = "at32ap", |
111 | .owner = THIS_MODULE, | ||
112 | .init = at32_cpufreq_driver_init, | 111 | .init = at32_cpufreq_driver_init, |
113 | .verify = at32_verify_speed, | 112 | .verify = at32_verify_speed, |
114 | .target = at32_set_target, | 113 | .target = at32_set_target, |
diff --git a/drivers/cpufreq/blackfin-cpufreq.c b/drivers/cpufreq/blackfin-cpufreq.c index 9cdbbd278a80..ef05978a7237 100644 --- a/drivers/cpufreq/blackfin-cpufreq.c +++ b/drivers/cpufreq/blackfin-cpufreq.c | |||
@@ -225,7 +225,6 @@ static struct cpufreq_driver bfin_driver = { | |||
225 | .get = bfin_getfreq_khz, | 225 | .get = bfin_getfreq_khz, |
226 | .init = __bfin_cpu_init, | 226 | .init = __bfin_cpu_init, |
227 | .name = "bfin cpufreq", | 227 | .name = "bfin cpufreq", |
228 | .owner = THIS_MODULE, | ||
229 | .attr = bfin_freq_attr, | 228 | .attr = bfin_freq_attr, |
230 | }; | 229 | }; |
231 | 230 | ||
diff --git a/drivers/cpufreq/cpufreq-cpu0.c b/drivers/cpufreq/cpufreq-cpu0.c index ad1fde277661..bad620e996e5 100644 --- a/drivers/cpufreq/cpufreq-cpu0.c +++ b/drivers/cpufreq/cpufreq-cpu0.c | |||
@@ -69,7 +69,7 @@ static int cpu0_set_target(struct cpufreq_policy *policy, | |||
69 | 69 | ||
70 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); | 70 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); |
71 | 71 | ||
72 | if (cpu_reg) { | 72 | if (!IS_ERR(cpu_reg)) { |
73 | rcu_read_lock(); | 73 | rcu_read_lock(); |
74 | opp = opp_find_freq_ceil(cpu_dev, &freq_Hz); | 74 | opp = opp_find_freq_ceil(cpu_dev, &freq_Hz); |
75 | if (IS_ERR(opp)) { | 75 | if (IS_ERR(opp)) { |
@@ -90,7 +90,7 @@ static int cpu0_set_target(struct cpufreq_policy *policy, | |||
90 | freqs.new / 1000, volt ? volt / 1000 : -1); | 90 | freqs.new / 1000, volt ? volt / 1000 : -1); |
91 | 91 | ||
92 | /* scaling up? scale voltage before frequency */ | 92 | /* scaling up? scale voltage before frequency */ |
93 | if (cpu_reg && freqs.new > freqs.old) { | 93 | if (!IS_ERR(cpu_reg) && freqs.new > freqs.old) { |
94 | ret = regulator_set_voltage_tol(cpu_reg, volt, tol); | 94 | ret = regulator_set_voltage_tol(cpu_reg, volt, tol); |
95 | if (ret) { | 95 | if (ret) { |
96 | pr_err("failed to scale voltage up: %d\n", ret); | 96 | pr_err("failed to scale voltage up: %d\n", ret); |
@@ -102,14 +102,14 @@ static int cpu0_set_target(struct cpufreq_policy *policy, | |||
102 | ret = clk_set_rate(cpu_clk, freq_exact); | 102 | ret = clk_set_rate(cpu_clk, freq_exact); |
103 | if (ret) { | 103 | if (ret) { |
104 | pr_err("failed to set clock rate: %d\n", ret); | 104 | pr_err("failed to set clock rate: %d\n", ret); |
105 | if (cpu_reg) | 105 | if (!IS_ERR(cpu_reg)) |
106 | regulator_set_voltage_tol(cpu_reg, volt_old, tol); | 106 | regulator_set_voltage_tol(cpu_reg, volt_old, tol); |
107 | freqs.new = freqs.old; | 107 | freqs.new = freqs.old; |
108 | goto post_notify; | 108 | goto post_notify; |
109 | } | 109 | } |
110 | 110 | ||
111 | /* scaling down? scale voltage after frequency */ | 111 | /* scaling down? scale voltage after frequency */ |
112 | if (cpu_reg && freqs.new < freqs.old) { | 112 | if (!IS_ERR(cpu_reg) && freqs.new < freqs.old) { |
113 | ret = regulator_set_voltage_tol(cpu_reg, volt, tol); | 113 | ret = regulator_set_voltage_tol(cpu_reg, volt, tol); |
114 | if (ret) { | 114 | if (ret) { |
115 | pr_err("failed to scale voltage down: %d\n", ret); | 115 | pr_err("failed to scale voltage down: %d\n", ret); |
@@ -174,29 +174,17 @@ static struct cpufreq_driver cpu0_cpufreq_driver = { | |||
174 | 174 | ||
175 | static int cpu0_cpufreq_probe(struct platform_device *pdev) | 175 | static int cpu0_cpufreq_probe(struct platform_device *pdev) |
176 | { | 176 | { |
177 | struct device_node *np, *parent; | 177 | struct device_node *np; |
178 | int ret; | 178 | int ret; |
179 | 179 | ||
180 | parent = of_find_node_by_path("/cpus"); | 180 | cpu_dev = &pdev->dev; |
181 | if (!parent) { | ||
182 | pr_err("failed to find OF /cpus\n"); | ||
183 | return -ENOENT; | ||
184 | } | ||
185 | |||
186 | for_each_child_of_node(parent, np) { | ||
187 | if (of_get_property(np, "operating-points", NULL)) | ||
188 | break; | ||
189 | } | ||
190 | 181 | ||
182 | np = of_node_get(cpu_dev->of_node); | ||
191 | if (!np) { | 183 | if (!np) { |
192 | pr_err("failed to find cpu0 node\n"); | 184 | pr_err("failed to find cpu0 node\n"); |
193 | ret = -ENOENT; | 185 | return -ENOENT; |
194 | goto out_put_parent; | ||
195 | } | 186 | } |
196 | 187 | ||
197 | cpu_dev = &pdev->dev; | ||
198 | cpu_dev->of_node = np; | ||
199 | |||
200 | cpu_reg = devm_regulator_get(cpu_dev, "cpu0"); | 188 | cpu_reg = devm_regulator_get(cpu_dev, "cpu0"); |
201 | if (IS_ERR(cpu_reg)) { | 189 | if (IS_ERR(cpu_reg)) { |
202 | /* | 190 | /* |
@@ -210,7 +198,6 @@ static int cpu0_cpufreq_probe(struct platform_device *pdev) | |||
210 | } | 198 | } |
211 | pr_warn("failed to get cpu0 regulator: %ld\n", | 199 | pr_warn("failed to get cpu0 regulator: %ld\n", |
212 | PTR_ERR(cpu_reg)); | 200 | PTR_ERR(cpu_reg)); |
213 | cpu_reg = NULL; | ||
214 | } | 201 | } |
215 | 202 | ||
216 | cpu_clk = devm_clk_get(cpu_dev, NULL); | 203 | cpu_clk = devm_clk_get(cpu_dev, NULL); |
@@ -269,15 +256,12 @@ static int cpu0_cpufreq_probe(struct platform_device *pdev) | |||
269 | } | 256 | } |
270 | 257 | ||
271 | of_node_put(np); | 258 | of_node_put(np); |
272 | of_node_put(parent); | ||
273 | return 0; | 259 | return 0; |
274 | 260 | ||
275 | out_free_table: | 261 | out_free_table: |
276 | opp_free_cpufreq_table(cpu_dev, &freq_table); | 262 | opp_free_cpufreq_table(cpu_dev, &freq_table); |
277 | out_put_node: | 263 | out_put_node: |
278 | of_node_put(np); | 264 | of_node_put(np); |
279 | out_put_parent: | ||
280 | of_node_put(parent); | ||
281 | return ret; | 265 | return ret; |
282 | } | 266 | } |
283 | 267 | ||
diff --git a/drivers/cpufreq/cpufreq-nforce2.c b/drivers/cpufreq/cpufreq-nforce2.c index af1542d41440..b83d45f68574 100644 --- a/drivers/cpufreq/cpufreq-nforce2.c +++ b/drivers/cpufreq/cpufreq-nforce2.c | |||
@@ -379,7 +379,6 @@ static struct cpufreq_driver nforce2_driver = { | |||
379 | .get = nforce2_get, | 379 | .get = nforce2_get, |
380 | .init = nforce2_cpu_init, | 380 | .init = nforce2_cpu_init, |
381 | .exit = nforce2_cpu_exit, | 381 | .exit = nforce2_cpu_exit, |
382 | .owner = THIS_MODULE, | ||
383 | }; | 382 | }; |
384 | 383 | ||
385 | #ifdef MODULE | 384 | #ifdef MODULE |
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index f0a5e2b0eb8a..5c75e3147a60 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c | |||
@@ -17,24 +17,17 @@ | |||
17 | 17 | ||
18 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | 18 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
19 | 19 | ||
20 | #include <asm/cputime.h> | 20 | #include <linux/cpu.h> |
21 | #include <linux/kernel.h> | ||
22 | #include <linux/kernel_stat.h> | ||
23 | #include <linux/module.h> | ||
24 | #include <linux/init.h> | ||
25 | #include <linux/notifier.h> | ||
26 | #include <linux/cpufreq.h> | 21 | #include <linux/cpufreq.h> |
27 | #include <linux/delay.h> | 22 | #include <linux/delay.h> |
28 | #include <linux/interrupt.h> | ||
29 | #include <linux/spinlock.h> | ||
30 | #include <linux/tick.h> | ||
31 | #include <linux/device.h> | 23 | #include <linux/device.h> |
32 | #include <linux/slab.h> | 24 | #include <linux/init.h> |
33 | #include <linux/cpu.h> | 25 | #include <linux/kernel_stat.h> |
34 | #include <linux/completion.h> | 26 | #include <linux/module.h> |
35 | #include <linux/mutex.h> | 27 | #include <linux/mutex.h> |
28 | #include <linux/slab.h> | ||
36 | #include <linux/syscore_ops.h> | 29 | #include <linux/syscore_ops.h> |
37 | 30 | #include <linux/tick.h> | |
38 | #include <trace/events/power.h> | 31 | #include <trace/events/power.h> |
39 | 32 | ||
40 | /** | 33 | /** |
@@ -44,8 +37,10 @@ | |||
44 | */ | 37 | */ |
45 | static struct cpufreq_driver *cpufreq_driver; | 38 | static struct cpufreq_driver *cpufreq_driver; |
46 | static DEFINE_PER_CPU(struct cpufreq_policy *, cpufreq_cpu_data); | 39 | static DEFINE_PER_CPU(struct cpufreq_policy *, cpufreq_cpu_data); |
40 | static DEFINE_PER_CPU(struct cpufreq_policy *, cpufreq_cpu_data_fallback); | ||
47 | static DEFINE_RWLOCK(cpufreq_driver_lock); | 41 | static DEFINE_RWLOCK(cpufreq_driver_lock); |
48 | static DEFINE_MUTEX(cpufreq_governor_lock); | 42 | static DEFINE_MUTEX(cpufreq_governor_lock); |
43 | static LIST_HEAD(cpufreq_policy_list); | ||
49 | 44 | ||
50 | #ifdef CONFIG_HOTPLUG_CPU | 45 | #ifdef CONFIG_HOTPLUG_CPU |
51 | /* This one keeps track of the previously set governor of a removed CPU */ | 46 | /* This one keeps track of the previously set governor of a removed CPU */ |
@@ -69,15 +64,14 @@ static DEFINE_PER_CPU(char[CPUFREQ_NAME_LEN], cpufreq_cpu_governor); | |||
69 | * - Lock should not be held across | 64 | * - Lock should not be held across |
70 | * __cpufreq_governor(data, CPUFREQ_GOV_STOP); | 65 | * __cpufreq_governor(data, CPUFREQ_GOV_STOP); |
71 | */ | 66 | */ |
72 | static DEFINE_PER_CPU(int, cpufreq_policy_cpu); | ||
73 | static DEFINE_PER_CPU(struct rw_semaphore, cpu_policy_rwsem); | 67 | static DEFINE_PER_CPU(struct rw_semaphore, cpu_policy_rwsem); |
74 | 68 | ||
75 | #define lock_policy_rwsem(mode, cpu) \ | 69 | #define lock_policy_rwsem(mode, cpu) \ |
76 | static int lock_policy_rwsem_##mode(int cpu) \ | 70 | static int lock_policy_rwsem_##mode(int cpu) \ |
77 | { \ | 71 | { \ |
78 | int policy_cpu = per_cpu(cpufreq_policy_cpu, cpu); \ | 72 | struct cpufreq_policy *policy = per_cpu(cpufreq_cpu_data, cpu); \ |
79 | BUG_ON(policy_cpu == -1); \ | 73 | BUG_ON(!policy); \ |
80 | down_##mode(&per_cpu(cpu_policy_rwsem, policy_cpu)); \ | 74 | down_##mode(&per_cpu(cpu_policy_rwsem, policy->cpu)); \ |
81 | \ | 75 | \ |
82 | return 0; \ | 76 | return 0; \ |
83 | } | 77 | } |
@@ -88,14 +82,20 @@ lock_policy_rwsem(write, cpu); | |||
88 | #define unlock_policy_rwsem(mode, cpu) \ | 82 | #define unlock_policy_rwsem(mode, cpu) \ |
89 | static void unlock_policy_rwsem_##mode(int cpu) \ | 83 | static void unlock_policy_rwsem_##mode(int cpu) \ |
90 | { \ | 84 | { \ |
91 | int policy_cpu = per_cpu(cpufreq_policy_cpu, cpu); \ | 85 | struct cpufreq_policy *policy = per_cpu(cpufreq_cpu_data, cpu); \ |
92 | BUG_ON(policy_cpu == -1); \ | 86 | BUG_ON(!policy); \ |
93 | up_##mode(&per_cpu(cpu_policy_rwsem, policy_cpu)); \ | 87 | up_##mode(&per_cpu(cpu_policy_rwsem, policy->cpu)); \ |
94 | } | 88 | } |
95 | 89 | ||
96 | unlock_policy_rwsem(read, cpu); | 90 | unlock_policy_rwsem(read, cpu); |
97 | unlock_policy_rwsem(write, cpu); | 91 | unlock_policy_rwsem(write, cpu); |
98 | 92 | ||
93 | /* | ||
94 | * rwsem to guarantee that cpufreq driver module doesn't unload during critical | ||
95 | * sections | ||
96 | */ | ||
97 | static DECLARE_RWSEM(cpufreq_rwsem); | ||
98 | |||
99 | /* internal prototypes */ | 99 | /* internal prototypes */ |
100 | static int __cpufreq_governor(struct cpufreq_policy *policy, | 100 | static int __cpufreq_governor(struct cpufreq_policy *policy, |
101 | unsigned int event); | 101 | unsigned int event); |
@@ -183,78 +183,46 @@ u64 get_cpu_idle_time(unsigned int cpu, u64 *wall, int io_busy) | |||
183 | } | 183 | } |
184 | EXPORT_SYMBOL_GPL(get_cpu_idle_time); | 184 | EXPORT_SYMBOL_GPL(get_cpu_idle_time); |
185 | 185 | ||
186 | static struct cpufreq_policy *__cpufreq_cpu_get(unsigned int cpu, bool sysfs) | 186 | struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu) |
187 | { | 187 | { |
188 | struct cpufreq_policy *data; | 188 | struct cpufreq_policy *policy = NULL; |
189 | unsigned long flags; | 189 | unsigned long flags; |
190 | 190 | ||
191 | if (cpu >= nr_cpu_ids) | 191 | if (cpufreq_disabled() || (cpu >= nr_cpu_ids)) |
192 | goto err_out; | 192 | return NULL; |
193 | |||
194 | if (!down_read_trylock(&cpufreq_rwsem)) | ||
195 | return NULL; | ||
193 | 196 | ||
194 | /* get the cpufreq driver */ | 197 | /* get the cpufreq driver */ |
195 | read_lock_irqsave(&cpufreq_driver_lock, flags); | 198 | read_lock_irqsave(&cpufreq_driver_lock, flags); |
196 | 199 | ||
197 | if (!cpufreq_driver) | 200 | if (cpufreq_driver) { |
198 | goto err_out_unlock; | 201 | /* get the CPU */ |
199 | 202 | policy = per_cpu(cpufreq_cpu_data, cpu); | |
200 | if (!try_module_get(cpufreq_driver->owner)) | 203 | if (policy) |
201 | goto err_out_unlock; | 204 | kobject_get(&policy->kobj); |
202 | 205 | } | |
203 | /* get the CPU */ | ||
204 | data = per_cpu(cpufreq_cpu_data, cpu); | ||
205 | |||
206 | if (!data) | ||
207 | goto err_out_put_module; | ||
208 | |||
209 | if (!sysfs && !kobject_get(&data->kobj)) | ||
210 | goto err_out_put_module; | ||
211 | 206 | ||
212 | read_unlock_irqrestore(&cpufreq_driver_lock, flags); | 207 | read_unlock_irqrestore(&cpufreq_driver_lock, flags); |
213 | return data; | ||
214 | 208 | ||
215 | err_out_put_module: | 209 | if (!policy) |
216 | module_put(cpufreq_driver->owner); | 210 | up_read(&cpufreq_rwsem); |
217 | err_out_unlock: | ||
218 | read_unlock_irqrestore(&cpufreq_driver_lock, flags); | ||
219 | err_out: | ||
220 | return NULL; | ||
221 | } | ||
222 | |||
223 | struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu) | ||
224 | { | ||
225 | if (cpufreq_disabled()) | ||
226 | return NULL; | ||
227 | 211 | ||
228 | return __cpufreq_cpu_get(cpu, false); | 212 | return policy; |
229 | } | 213 | } |
230 | EXPORT_SYMBOL_GPL(cpufreq_cpu_get); | 214 | EXPORT_SYMBOL_GPL(cpufreq_cpu_get); |
231 | 215 | ||
232 | static struct cpufreq_policy *cpufreq_cpu_get_sysfs(unsigned int cpu) | 216 | void cpufreq_cpu_put(struct cpufreq_policy *policy) |
233 | { | ||
234 | return __cpufreq_cpu_get(cpu, true); | ||
235 | } | ||
236 | |||
237 | static void __cpufreq_cpu_put(struct cpufreq_policy *data, bool sysfs) | ||
238 | { | ||
239 | if (!sysfs) | ||
240 | kobject_put(&data->kobj); | ||
241 | module_put(cpufreq_driver->owner); | ||
242 | } | ||
243 | |||
244 | void cpufreq_cpu_put(struct cpufreq_policy *data) | ||
245 | { | 217 | { |
246 | if (cpufreq_disabled()) | 218 | if (cpufreq_disabled()) |
247 | return; | 219 | return; |
248 | 220 | ||
249 | __cpufreq_cpu_put(data, false); | 221 | kobject_put(&policy->kobj); |
222 | up_read(&cpufreq_rwsem); | ||
250 | } | 223 | } |
251 | EXPORT_SYMBOL_GPL(cpufreq_cpu_put); | 224 | EXPORT_SYMBOL_GPL(cpufreq_cpu_put); |
252 | 225 | ||
253 | static void cpufreq_cpu_put_sysfs(struct cpufreq_policy *data) | ||
254 | { | ||
255 | __cpufreq_cpu_put(data, true); | ||
256 | } | ||
257 | |||
258 | /********************************************************************* | 226 | /********************************************************************* |
259 | * EXTERNALLY AFFECTING FREQUENCY CHANGES * | 227 | * EXTERNALLY AFFECTING FREQUENCY CHANGES * |
260 | *********************************************************************/ | 228 | *********************************************************************/ |
@@ -459,8 +427,8 @@ show_one(scaling_min_freq, min); | |||
459 | show_one(scaling_max_freq, max); | 427 | show_one(scaling_max_freq, max); |
460 | show_one(scaling_cur_freq, cur); | 428 | show_one(scaling_cur_freq, cur); |
461 | 429 | ||
462 | static int __cpufreq_set_policy(struct cpufreq_policy *data, | 430 | static int __cpufreq_set_policy(struct cpufreq_policy *policy, |
463 | struct cpufreq_policy *policy); | 431 | struct cpufreq_policy *new_policy); |
464 | 432 | ||
465 | /** | 433 | /** |
466 | * cpufreq_per_cpu_attr_write() / store_##file_name() - sysfs write access | 434 | * cpufreq_per_cpu_attr_write() / store_##file_name() - sysfs write access |
@@ -699,12 +667,12 @@ static ssize_t show(struct kobject *kobj, struct attribute *attr, char *buf) | |||
699 | struct cpufreq_policy *policy = to_policy(kobj); | 667 | struct cpufreq_policy *policy = to_policy(kobj); |
700 | struct freq_attr *fattr = to_attr(attr); | 668 | struct freq_attr *fattr = to_attr(attr); |
701 | ssize_t ret = -EINVAL; | 669 | ssize_t ret = -EINVAL; |
702 | policy = cpufreq_cpu_get_sysfs(policy->cpu); | 670 | |
703 | if (!policy) | 671 | if (!down_read_trylock(&cpufreq_rwsem)) |
704 | goto no_policy; | 672 | goto exit; |
705 | 673 | ||
706 | if (lock_policy_rwsem_read(policy->cpu) < 0) | 674 | if (lock_policy_rwsem_read(policy->cpu) < 0) |
707 | goto fail; | 675 | goto up_read; |
708 | 676 | ||
709 | if (fattr->show) | 677 | if (fattr->show) |
710 | ret = fattr->show(policy, buf); | 678 | ret = fattr->show(policy, buf); |
@@ -712,9 +680,10 @@ static ssize_t show(struct kobject *kobj, struct attribute *attr, char *buf) | |||
712 | ret = -EIO; | 680 | ret = -EIO; |
713 | 681 | ||
714 | unlock_policy_rwsem_read(policy->cpu); | 682 | unlock_policy_rwsem_read(policy->cpu); |
715 | fail: | 683 | |
716 | cpufreq_cpu_put_sysfs(policy); | 684 | up_read: |
717 | no_policy: | 685 | up_read(&cpufreq_rwsem); |
686 | exit: | ||
718 | return ret; | 687 | return ret; |
719 | } | 688 | } |
720 | 689 | ||
@@ -724,12 +693,12 @@ static ssize_t store(struct kobject *kobj, struct attribute *attr, | |||
724 | struct cpufreq_policy *policy = to_policy(kobj); | 693 | struct cpufreq_policy *policy = to_policy(kobj); |
725 | struct freq_attr *fattr = to_attr(attr); | 694 | struct freq_attr *fattr = to_attr(attr); |
726 | ssize_t ret = -EINVAL; | 695 | ssize_t ret = -EINVAL; |
727 | policy = cpufreq_cpu_get_sysfs(policy->cpu); | 696 | |
728 | if (!policy) | 697 | if (!down_read_trylock(&cpufreq_rwsem)) |
729 | goto no_policy; | 698 | goto exit; |
730 | 699 | ||
731 | if (lock_policy_rwsem_write(policy->cpu) < 0) | 700 | if (lock_policy_rwsem_write(policy->cpu) < 0) |
732 | goto fail; | 701 | goto up_read; |
733 | 702 | ||
734 | if (fattr->store) | 703 | if (fattr->store) |
735 | ret = fattr->store(policy, buf, count); | 704 | ret = fattr->store(policy, buf, count); |
@@ -737,9 +706,10 @@ static ssize_t store(struct kobject *kobj, struct attribute *attr, | |||
737 | ret = -EIO; | 706 | ret = -EIO; |
738 | 707 | ||
739 | unlock_policy_rwsem_write(policy->cpu); | 708 | unlock_policy_rwsem_write(policy->cpu); |
740 | fail: | 709 | |
741 | cpufreq_cpu_put_sysfs(policy); | 710 | up_read: |
742 | no_policy: | 711 | up_read(&cpufreq_rwsem); |
712 | exit: | ||
743 | return ret; | 713 | return ret; |
744 | } | 714 | } |
745 | 715 | ||
@@ -805,41 +775,32 @@ void cpufreq_sysfs_remove_file(const struct attribute *attr) | |||
805 | EXPORT_SYMBOL(cpufreq_sysfs_remove_file); | 775 | EXPORT_SYMBOL(cpufreq_sysfs_remove_file); |
806 | 776 | ||
807 | /* symlink affected CPUs */ | 777 | /* symlink affected CPUs */ |
808 | static int cpufreq_add_dev_symlink(unsigned int cpu, | 778 | static int cpufreq_add_dev_symlink(struct cpufreq_policy *policy) |
809 | struct cpufreq_policy *policy) | ||
810 | { | 779 | { |
811 | unsigned int j; | 780 | unsigned int j; |
812 | int ret = 0; | 781 | int ret = 0; |
813 | 782 | ||
814 | for_each_cpu(j, policy->cpus) { | 783 | for_each_cpu(j, policy->cpus) { |
815 | struct cpufreq_policy *managed_policy; | ||
816 | struct device *cpu_dev; | 784 | struct device *cpu_dev; |
817 | 785 | ||
818 | if (j == cpu) | 786 | if (j == policy->cpu) |
819 | continue; | 787 | continue; |
820 | 788 | ||
821 | pr_debug("CPU %u already managed, adding link\n", j); | 789 | pr_debug("Adding link for CPU: %u\n", j); |
822 | managed_policy = cpufreq_cpu_get(cpu); | ||
823 | cpu_dev = get_cpu_device(j); | 790 | cpu_dev = get_cpu_device(j); |
824 | ret = sysfs_create_link(&cpu_dev->kobj, &policy->kobj, | 791 | ret = sysfs_create_link(&cpu_dev->kobj, &policy->kobj, |
825 | "cpufreq"); | 792 | "cpufreq"); |
826 | if (ret) { | 793 | if (ret) |
827 | cpufreq_cpu_put(managed_policy); | 794 | break; |
828 | return ret; | ||
829 | } | ||
830 | } | 795 | } |
831 | return ret; | 796 | return ret; |
832 | } | 797 | } |
833 | 798 | ||
834 | static int cpufreq_add_dev_interface(unsigned int cpu, | 799 | static int cpufreq_add_dev_interface(struct cpufreq_policy *policy, |
835 | struct cpufreq_policy *policy, | ||
836 | struct device *dev) | 800 | struct device *dev) |
837 | { | 801 | { |
838 | struct cpufreq_policy new_policy; | ||
839 | struct freq_attr **drv_attr; | 802 | struct freq_attr **drv_attr; |
840 | unsigned long flags; | ||
841 | int ret = 0; | 803 | int ret = 0; |
842 | unsigned int j; | ||
843 | 804 | ||
844 | /* prepare interface data */ | 805 | /* prepare interface data */ |
845 | ret = kobject_init_and_add(&policy->kobj, &ktype_cpufreq, | 806 | ret = kobject_init_and_add(&policy->kobj, &ktype_cpufreq, |
@@ -871,18 +832,24 @@ static int cpufreq_add_dev_interface(unsigned int cpu, | |||
871 | goto err_out_kobj_put; | 832 | goto err_out_kobj_put; |
872 | } | 833 | } |
873 | 834 | ||
874 | write_lock_irqsave(&cpufreq_driver_lock, flags); | 835 | ret = cpufreq_add_dev_symlink(policy); |
875 | for_each_cpu(j, policy->cpus) { | ||
876 | per_cpu(cpufreq_cpu_data, j) = policy; | ||
877 | per_cpu(cpufreq_policy_cpu, j) = policy->cpu; | ||
878 | } | ||
879 | write_unlock_irqrestore(&cpufreq_driver_lock, flags); | ||
880 | |||
881 | ret = cpufreq_add_dev_symlink(cpu, policy); | ||
882 | if (ret) | 836 | if (ret) |
883 | goto err_out_kobj_put; | 837 | goto err_out_kobj_put; |
884 | 838 | ||
885 | memcpy(&new_policy, policy, sizeof(struct cpufreq_policy)); | 839 | return ret; |
840 | |||
841 | err_out_kobj_put: | ||
842 | kobject_put(&policy->kobj); | ||
843 | wait_for_completion(&policy->kobj_unregister); | ||
844 | return ret; | ||
845 | } | ||
846 | |||
847 | static void cpufreq_init_policy(struct cpufreq_policy *policy) | ||
848 | { | ||
849 | struct cpufreq_policy new_policy; | ||
850 | int ret = 0; | ||
851 | |||
852 | memcpy(&new_policy, policy, sizeof(*policy)); | ||
886 | /* assure that the starting sequence is run in __cpufreq_set_policy */ | 853 | /* assure that the starting sequence is run in __cpufreq_set_policy */ |
887 | policy->governor = NULL; | 854 | policy->governor = NULL; |
888 | 855 | ||
@@ -896,72 +863,106 @@ static int cpufreq_add_dev_interface(unsigned int cpu, | |||
896 | if (cpufreq_driver->exit) | 863 | if (cpufreq_driver->exit) |
897 | cpufreq_driver->exit(policy); | 864 | cpufreq_driver->exit(policy); |
898 | } | 865 | } |
899 | return ret; | ||
900 | |||
901 | err_out_kobj_put: | ||
902 | kobject_put(&policy->kobj); | ||
903 | wait_for_completion(&policy->kobj_unregister); | ||
904 | return ret; | ||
905 | } | 866 | } |
906 | 867 | ||
907 | #ifdef CONFIG_HOTPLUG_CPU | 868 | #ifdef CONFIG_HOTPLUG_CPU |
908 | static int cpufreq_add_policy_cpu(unsigned int cpu, unsigned int sibling, | 869 | static int cpufreq_add_policy_cpu(struct cpufreq_policy *policy, |
909 | struct device *dev) | 870 | unsigned int cpu, struct device *dev, |
871 | bool frozen) | ||
910 | { | 872 | { |
911 | struct cpufreq_policy *policy; | ||
912 | int ret = 0, has_target = !!cpufreq_driver->target; | 873 | int ret = 0, has_target = !!cpufreq_driver->target; |
913 | unsigned long flags; | 874 | unsigned long flags; |
914 | 875 | ||
915 | policy = cpufreq_cpu_get(sibling); | 876 | if (has_target) { |
916 | WARN_ON(!policy); | 877 | ret = __cpufreq_governor(policy, CPUFREQ_GOV_STOP); |
917 | 878 | if (ret) { | |
918 | if (has_target) | 879 | pr_err("%s: Failed to stop governor\n", __func__); |
919 | __cpufreq_governor(policy, CPUFREQ_GOV_STOP); | 880 | return ret; |
881 | } | ||
882 | } | ||
920 | 883 | ||
921 | lock_policy_rwsem_write(sibling); | 884 | lock_policy_rwsem_write(policy->cpu); |
922 | 885 | ||
923 | write_lock_irqsave(&cpufreq_driver_lock, flags); | 886 | write_lock_irqsave(&cpufreq_driver_lock, flags); |
924 | 887 | ||
925 | cpumask_set_cpu(cpu, policy->cpus); | 888 | cpumask_set_cpu(cpu, policy->cpus); |
926 | per_cpu(cpufreq_policy_cpu, cpu) = policy->cpu; | ||
927 | per_cpu(cpufreq_cpu_data, cpu) = policy; | 889 | per_cpu(cpufreq_cpu_data, cpu) = policy; |
928 | write_unlock_irqrestore(&cpufreq_driver_lock, flags); | 890 | write_unlock_irqrestore(&cpufreq_driver_lock, flags); |
929 | 891 | ||
930 | unlock_policy_rwsem_write(sibling); | 892 | unlock_policy_rwsem_write(policy->cpu); |
931 | 893 | ||
932 | if (has_target) { | 894 | if (has_target) { |
933 | __cpufreq_governor(policy, CPUFREQ_GOV_START); | 895 | if ((ret = __cpufreq_governor(policy, CPUFREQ_GOV_START)) || |
934 | __cpufreq_governor(policy, CPUFREQ_GOV_LIMITS); | 896 | (ret = __cpufreq_governor(policy, CPUFREQ_GOV_LIMITS))) { |
897 | pr_err("%s: Failed to start governor\n", __func__); | ||
898 | return ret; | ||
899 | } | ||
935 | } | 900 | } |
936 | 901 | ||
937 | ret = sysfs_create_link(&dev->kobj, &policy->kobj, "cpufreq"); | 902 | /* Don't touch sysfs links during light-weight init */ |
938 | if (ret) { | 903 | if (!frozen) |
939 | cpufreq_cpu_put(policy); | 904 | ret = sysfs_create_link(&dev->kobj, &policy->kobj, "cpufreq"); |
940 | return ret; | ||
941 | } | ||
942 | 905 | ||
943 | return 0; | 906 | return ret; |
944 | } | 907 | } |
945 | #endif | 908 | #endif |
946 | 909 | ||
947 | /** | 910 | static struct cpufreq_policy *cpufreq_policy_restore(unsigned int cpu) |
948 | * cpufreq_add_dev - add a CPU device | 911 | { |
949 | * | 912 | struct cpufreq_policy *policy; |
950 | * Adds the cpufreq interface for a CPU device. | 913 | unsigned long flags; |
951 | * | 914 | |
952 | * The Oracle says: try running cpufreq registration/unregistration concurrently | 915 | write_lock_irqsave(&cpufreq_driver_lock, flags); |
953 | * with with cpu hotplugging and all hell will break loose. Tried to clean this | 916 | |
954 | * mess up, but more thorough testing is needed. - Mathieu | 917 | policy = per_cpu(cpufreq_cpu_data_fallback, cpu); |
955 | */ | 918 | |
956 | static int cpufreq_add_dev(struct device *dev, struct subsys_interface *sif) | 919 | write_unlock_irqrestore(&cpufreq_driver_lock, flags); |
920 | |||
921 | return policy; | ||
922 | } | ||
923 | |||
924 | static struct cpufreq_policy *cpufreq_policy_alloc(void) | ||
925 | { | ||
926 | struct cpufreq_policy *policy; | ||
927 | |||
928 | policy = kzalloc(sizeof(*policy), GFP_KERNEL); | ||
929 | if (!policy) | ||
930 | return NULL; | ||
931 | |||
932 | if (!alloc_cpumask_var(&policy->cpus, GFP_KERNEL)) | ||
933 | goto err_free_policy; | ||
934 | |||
935 | if (!zalloc_cpumask_var(&policy->related_cpus, GFP_KERNEL)) | ||
936 | goto err_free_cpumask; | ||
937 | |||
938 | INIT_LIST_HEAD(&policy->policy_list); | ||
939 | return policy; | ||
940 | |||
941 | err_free_cpumask: | ||
942 | free_cpumask_var(policy->cpus); | ||
943 | err_free_policy: | ||
944 | kfree(policy); | ||
945 | |||
946 | return NULL; | ||
947 | } | ||
948 | |||
949 | static void cpufreq_policy_free(struct cpufreq_policy *policy) | ||
950 | { | ||
951 | free_cpumask_var(policy->related_cpus); | ||
952 | free_cpumask_var(policy->cpus); | ||
953 | kfree(policy); | ||
954 | } | ||
955 | |||
956 | static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif, | ||
957 | bool frozen) | ||
957 | { | 958 | { |
958 | unsigned int j, cpu = dev->id; | 959 | unsigned int j, cpu = dev->id; |
959 | int ret = -ENOMEM; | 960 | int ret = -ENOMEM; |
960 | struct cpufreq_policy *policy; | 961 | struct cpufreq_policy *policy; |
961 | unsigned long flags; | 962 | unsigned long flags; |
962 | #ifdef CONFIG_HOTPLUG_CPU | 963 | #ifdef CONFIG_HOTPLUG_CPU |
964 | struct cpufreq_policy *tpolicy; | ||
963 | struct cpufreq_governor *gov; | 965 | struct cpufreq_governor *gov; |
964 | int sibling; | ||
965 | #endif | 966 | #endif |
966 | 967 | ||
967 | if (cpu_is_offline(cpu)) | 968 | if (cpu_is_offline(cpu)) |
@@ -977,43 +978,38 @@ static int cpufreq_add_dev(struct device *dev, struct subsys_interface *sif) | |||
977 | cpufreq_cpu_put(policy); | 978 | cpufreq_cpu_put(policy); |
978 | return 0; | 979 | return 0; |
979 | } | 980 | } |
981 | #endif | ||
982 | |||
983 | if (!down_read_trylock(&cpufreq_rwsem)) | ||
984 | return 0; | ||
980 | 985 | ||
981 | #ifdef CONFIG_HOTPLUG_CPU | 986 | #ifdef CONFIG_HOTPLUG_CPU |
982 | /* Check if this cpu was hot-unplugged earlier and has siblings */ | 987 | /* Check if this cpu was hot-unplugged earlier and has siblings */ |
983 | read_lock_irqsave(&cpufreq_driver_lock, flags); | 988 | read_lock_irqsave(&cpufreq_driver_lock, flags); |
984 | for_each_online_cpu(sibling) { | 989 | list_for_each_entry(tpolicy, &cpufreq_policy_list, policy_list) { |
985 | struct cpufreq_policy *cp = per_cpu(cpufreq_cpu_data, sibling); | 990 | if (cpumask_test_cpu(cpu, tpolicy->related_cpus)) { |
986 | if (cp && cpumask_test_cpu(cpu, cp->related_cpus)) { | ||
987 | read_unlock_irqrestore(&cpufreq_driver_lock, flags); | 991 | read_unlock_irqrestore(&cpufreq_driver_lock, flags); |
988 | return cpufreq_add_policy_cpu(cpu, sibling, dev); | 992 | ret = cpufreq_add_policy_cpu(tpolicy, cpu, dev, frozen); |
993 | up_read(&cpufreq_rwsem); | ||
994 | return ret; | ||
989 | } | 995 | } |
990 | } | 996 | } |
991 | read_unlock_irqrestore(&cpufreq_driver_lock, flags); | 997 | read_unlock_irqrestore(&cpufreq_driver_lock, flags); |
992 | #endif | 998 | #endif |
993 | #endif | ||
994 | 999 | ||
995 | if (!try_module_get(cpufreq_driver->owner)) { | 1000 | if (frozen) |
996 | ret = -EINVAL; | 1001 | /* Restore the saved policy when doing light-weight init */ |
997 | goto module_out; | 1002 | policy = cpufreq_policy_restore(cpu); |
998 | } | 1003 | else |
1004 | policy = cpufreq_policy_alloc(); | ||
999 | 1005 | ||
1000 | policy = kzalloc(sizeof(struct cpufreq_policy), GFP_KERNEL); | ||
1001 | if (!policy) | 1006 | if (!policy) |
1002 | goto nomem_out; | 1007 | goto nomem_out; |
1003 | 1008 | ||
1004 | if (!alloc_cpumask_var(&policy->cpus, GFP_KERNEL)) | ||
1005 | goto err_free_policy; | ||
1006 | |||
1007 | if (!zalloc_cpumask_var(&policy->related_cpus, GFP_KERNEL)) | ||
1008 | goto err_free_cpumask; | ||
1009 | |||
1010 | policy->cpu = cpu; | 1009 | policy->cpu = cpu; |
1011 | policy->governor = CPUFREQ_DEFAULT_GOVERNOR; | 1010 | policy->governor = CPUFREQ_DEFAULT_GOVERNOR; |
1012 | cpumask_copy(policy->cpus, cpumask_of(cpu)); | 1011 | cpumask_copy(policy->cpus, cpumask_of(cpu)); |
1013 | 1012 | ||
1014 | /* Initially set CPU itself as the policy_cpu */ | ||
1015 | per_cpu(cpufreq_policy_cpu, cpu) = cpu; | ||
1016 | |||
1017 | init_completion(&policy->kobj_unregister); | 1013 | init_completion(&policy->kobj_unregister); |
1018 | INIT_WORK(&policy->update, handle_update); | 1014 | INIT_WORK(&policy->update, handle_update); |
1019 | 1015 | ||
@@ -1050,12 +1046,26 @@ static int cpufreq_add_dev(struct device *dev, struct subsys_interface *sif) | |||
1050 | } | 1046 | } |
1051 | #endif | 1047 | #endif |
1052 | 1048 | ||
1053 | ret = cpufreq_add_dev_interface(cpu, policy, dev); | 1049 | write_lock_irqsave(&cpufreq_driver_lock, flags); |
1054 | if (ret) | 1050 | for_each_cpu(j, policy->cpus) |
1055 | goto err_out_unregister; | 1051 | per_cpu(cpufreq_cpu_data, j) = policy; |
1052 | write_unlock_irqrestore(&cpufreq_driver_lock, flags); | ||
1053 | |||
1054 | if (!frozen) { | ||
1055 | ret = cpufreq_add_dev_interface(policy, dev); | ||
1056 | if (ret) | ||
1057 | goto err_out_unregister; | ||
1058 | } | ||
1059 | |||
1060 | write_lock_irqsave(&cpufreq_driver_lock, flags); | ||
1061 | list_add(&policy->policy_list, &cpufreq_policy_list); | ||
1062 | write_unlock_irqrestore(&cpufreq_driver_lock, flags); | ||
1063 | |||
1064 | cpufreq_init_policy(policy); | ||
1056 | 1065 | ||
1057 | kobject_uevent(&policy->kobj, KOBJ_ADD); | 1066 | kobject_uevent(&policy->kobj, KOBJ_ADD); |
1058 | module_put(cpufreq_driver->owner); | 1067 | up_read(&cpufreq_rwsem); |
1068 | |||
1059 | pr_debug("initialization complete\n"); | 1069 | pr_debug("initialization complete\n"); |
1060 | 1070 | ||
1061 | return 0; | 1071 | return 0; |
@@ -1066,32 +1076,33 @@ err_out_unregister: | |||
1066 | per_cpu(cpufreq_cpu_data, j) = NULL; | 1076 | per_cpu(cpufreq_cpu_data, j) = NULL; |
1067 | write_unlock_irqrestore(&cpufreq_driver_lock, flags); | 1077 | write_unlock_irqrestore(&cpufreq_driver_lock, flags); |
1068 | 1078 | ||
1069 | kobject_put(&policy->kobj); | ||
1070 | wait_for_completion(&policy->kobj_unregister); | ||
1071 | |||
1072 | err_set_policy_cpu: | 1079 | err_set_policy_cpu: |
1073 | per_cpu(cpufreq_policy_cpu, cpu) = -1; | 1080 | cpufreq_policy_free(policy); |
1074 | free_cpumask_var(policy->related_cpus); | ||
1075 | err_free_cpumask: | ||
1076 | free_cpumask_var(policy->cpus); | ||
1077 | err_free_policy: | ||
1078 | kfree(policy); | ||
1079 | nomem_out: | 1081 | nomem_out: |
1080 | module_put(cpufreq_driver->owner); | 1082 | up_read(&cpufreq_rwsem); |
1081 | module_out: | 1083 | |
1082 | return ret; | 1084 | return ret; |
1083 | } | 1085 | } |
1084 | 1086 | ||
1085 | static void update_policy_cpu(struct cpufreq_policy *policy, unsigned int cpu) | 1087 | /** |
1088 | * cpufreq_add_dev - add a CPU device | ||
1089 | * | ||
1090 | * Adds the cpufreq interface for a CPU device. | ||
1091 | * | ||
1092 | * The Oracle says: try running cpufreq registration/unregistration concurrently | ||
1093 | * with with cpu hotplugging and all hell will break loose. Tried to clean this | ||
1094 | * mess up, but more thorough testing is needed. - Mathieu | ||
1095 | */ | ||
1096 | static int cpufreq_add_dev(struct device *dev, struct subsys_interface *sif) | ||
1086 | { | 1097 | { |
1087 | int j; | 1098 | return __cpufreq_add_dev(dev, sif, false); |
1099 | } | ||
1088 | 1100 | ||
1101 | static void update_policy_cpu(struct cpufreq_policy *policy, unsigned int cpu) | ||
1102 | { | ||
1089 | policy->last_cpu = policy->cpu; | 1103 | policy->last_cpu = policy->cpu; |
1090 | policy->cpu = cpu; | 1104 | policy->cpu = cpu; |
1091 | 1105 | ||
1092 | for_each_cpu(j, policy->cpus) | ||
1093 | per_cpu(cpufreq_policy_cpu, j) = cpu; | ||
1094 | |||
1095 | #ifdef CONFIG_CPU_FREQ_TABLE | 1106 | #ifdef CONFIG_CPU_FREQ_TABLE |
1096 | cpufreq_frequency_table_update_policy_cpu(policy); | 1107 | cpufreq_frequency_table_update_policy_cpu(policy); |
1097 | #endif | 1108 | #endif |
@@ -1099,6 +1110,37 @@ static void update_policy_cpu(struct cpufreq_policy *policy, unsigned int cpu) | |||
1099 | CPUFREQ_UPDATE_POLICY_CPU, policy); | 1110 | CPUFREQ_UPDATE_POLICY_CPU, policy); |
1100 | } | 1111 | } |
1101 | 1112 | ||
1113 | static int cpufreq_nominate_new_policy_cpu(struct cpufreq_policy *policy, | ||
1114 | unsigned int old_cpu, bool frozen) | ||
1115 | { | ||
1116 | struct device *cpu_dev; | ||
1117 | int ret; | ||
1118 | |||
1119 | /* first sibling now owns the new sysfs dir */ | ||
1120 | cpu_dev = get_cpu_device(cpumask_first(policy->cpus)); | ||
1121 | |||
1122 | /* Don't touch sysfs files during light-weight tear-down */ | ||
1123 | if (frozen) | ||
1124 | return cpu_dev->id; | ||
1125 | |||
1126 | sysfs_remove_link(&cpu_dev->kobj, "cpufreq"); | ||
1127 | ret = kobject_move(&policy->kobj, &cpu_dev->kobj); | ||
1128 | if (ret) { | ||
1129 | pr_err("%s: Failed to move kobj: %d", __func__, ret); | ||
1130 | |||
1131 | WARN_ON(lock_policy_rwsem_write(old_cpu)); | ||
1132 | cpumask_set_cpu(old_cpu, policy->cpus); | ||
1133 | unlock_policy_rwsem_write(old_cpu); | ||
1134 | |||
1135 | ret = sysfs_create_link(&cpu_dev->kobj, &policy->kobj, | ||
1136 | "cpufreq"); | ||
1137 | |||
1138 | return -EINVAL; | ||
1139 | } | ||
1140 | |||
1141 | return cpu_dev->id; | ||
1142 | } | ||
1143 | |||
1102 | /** | 1144 | /** |
1103 | * __cpufreq_remove_dev - remove a CPU device | 1145 | * __cpufreq_remove_dev - remove a CPU device |
1104 | * | 1146 | * |
@@ -1107,111 +1149,126 @@ static void update_policy_cpu(struct cpufreq_policy *policy, unsigned int cpu) | |||
1107 | * This routine frees the rwsem before returning. | 1149 | * This routine frees the rwsem before returning. |
1108 | */ | 1150 | */ |
1109 | static int __cpufreq_remove_dev(struct device *dev, | 1151 | static int __cpufreq_remove_dev(struct device *dev, |
1110 | struct subsys_interface *sif) | 1152 | struct subsys_interface *sif, bool frozen) |
1111 | { | 1153 | { |
1112 | unsigned int cpu = dev->id, ret, cpus; | 1154 | unsigned int cpu = dev->id, cpus; |
1155 | int new_cpu, ret; | ||
1113 | unsigned long flags; | 1156 | unsigned long flags; |
1114 | struct cpufreq_policy *data; | 1157 | struct cpufreq_policy *policy; |
1115 | struct kobject *kobj; | 1158 | struct kobject *kobj; |
1116 | struct completion *cmp; | 1159 | struct completion *cmp; |
1117 | struct device *cpu_dev; | ||
1118 | 1160 | ||
1119 | pr_debug("%s: unregistering CPU %u\n", __func__, cpu); | 1161 | pr_debug("%s: unregistering CPU %u\n", __func__, cpu); |
1120 | 1162 | ||
1121 | write_lock_irqsave(&cpufreq_driver_lock, flags); | 1163 | write_lock_irqsave(&cpufreq_driver_lock, flags); |
1122 | 1164 | ||
1123 | data = per_cpu(cpufreq_cpu_data, cpu); | 1165 | policy = per_cpu(cpufreq_cpu_data, cpu); |
1124 | per_cpu(cpufreq_cpu_data, cpu) = NULL; | 1166 | |
1167 | /* Save the policy somewhere when doing a light-weight tear-down */ | ||
1168 | if (frozen) | ||
1169 | per_cpu(cpufreq_cpu_data_fallback, cpu) = policy; | ||
1125 | 1170 | ||
1126 | write_unlock_irqrestore(&cpufreq_driver_lock, flags); | 1171 | write_unlock_irqrestore(&cpufreq_driver_lock, flags); |
1127 | 1172 | ||
1128 | if (!data) { | 1173 | if (!policy) { |
1129 | pr_debug("%s: No cpu_data found\n", __func__); | 1174 | pr_debug("%s: No cpu_data found\n", __func__); |
1130 | return -EINVAL; | 1175 | return -EINVAL; |
1131 | } | 1176 | } |
1132 | 1177 | ||
1133 | if (cpufreq_driver->target) | 1178 | if (cpufreq_driver->target) { |
1134 | __cpufreq_governor(data, CPUFREQ_GOV_STOP); | 1179 | ret = __cpufreq_governor(policy, CPUFREQ_GOV_STOP); |
1180 | if (ret) { | ||
1181 | pr_err("%s: Failed to stop governor\n", __func__); | ||
1182 | return ret; | ||
1183 | } | ||
1184 | } | ||
1135 | 1185 | ||
1136 | #ifdef CONFIG_HOTPLUG_CPU | 1186 | #ifdef CONFIG_HOTPLUG_CPU |
1137 | if (!cpufreq_driver->setpolicy) | 1187 | if (!cpufreq_driver->setpolicy) |
1138 | strncpy(per_cpu(cpufreq_cpu_governor, cpu), | 1188 | strncpy(per_cpu(cpufreq_cpu_governor, cpu), |
1139 | data->governor->name, CPUFREQ_NAME_LEN); | 1189 | policy->governor->name, CPUFREQ_NAME_LEN); |
1140 | #endif | 1190 | #endif |
1141 | 1191 | ||
1142 | WARN_ON(lock_policy_rwsem_write(cpu)); | 1192 | WARN_ON(lock_policy_rwsem_write(cpu)); |
1143 | cpus = cpumask_weight(data->cpus); | 1193 | cpus = cpumask_weight(policy->cpus); |
1144 | 1194 | ||
1145 | if (cpus > 1) | 1195 | if (cpus > 1) |
1146 | cpumask_clear_cpu(cpu, data->cpus); | 1196 | cpumask_clear_cpu(cpu, policy->cpus); |
1147 | unlock_policy_rwsem_write(cpu); | 1197 | unlock_policy_rwsem_write(cpu); |
1148 | 1198 | ||
1149 | if (cpu != data->cpu) { | 1199 | if (cpu != policy->cpu && !frozen) { |
1150 | sysfs_remove_link(&dev->kobj, "cpufreq"); | 1200 | sysfs_remove_link(&dev->kobj, "cpufreq"); |
1151 | } else if (cpus > 1) { | 1201 | } else if (cpus > 1) { |
1152 | /* first sibling now owns the new sysfs dir */ | ||
1153 | cpu_dev = get_cpu_device(cpumask_first(data->cpus)); | ||
1154 | sysfs_remove_link(&cpu_dev->kobj, "cpufreq"); | ||
1155 | ret = kobject_move(&data->kobj, &cpu_dev->kobj); | ||
1156 | if (ret) { | ||
1157 | pr_err("%s: Failed to move kobj: %d", __func__, ret); | ||
1158 | 1202 | ||
1203 | new_cpu = cpufreq_nominate_new_policy_cpu(policy, cpu, frozen); | ||
1204 | if (new_cpu >= 0) { | ||
1159 | WARN_ON(lock_policy_rwsem_write(cpu)); | 1205 | WARN_ON(lock_policy_rwsem_write(cpu)); |
1160 | cpumask_set_cpu(cpu, data->cpus); | 1206 | update_policy_cpu(policy, new_cpu); |
1161 | |||
1162 | write_lock_irqsave(&cpufreq_driver_lock, flags); | ||
1163 | per_cpu(cpufreq_cpu_data, cpu) = data; | ||
1164 | write_unlock_irqrestore(&cpufreq_driver_lock, flags); | ||
1165 | |||
1166 | unlock_policy_rwsem_write(cpu); | 1207 | unlock_policy_rwsem_write(cpu); |
1167 | 1208 | ||
1168 | ret = sysfs_create_link(&cpu_dev->kobj, &data->kobj, | 1209 | if (!frozen) { |
1169 | "cpufreq"); | 1210 | pr_debug("%s: policy Kobject moved to cpu: %d " |
1170 | return -EINVAL; | 1211 | "from: %d\n",__func__, new_cpu, cpu); |
1212 | } | ||
1171 | } | 1213 | } |
1172 | |||
1173 | WARN_ON(lock_policy_rwsem_write(cpu)); | ||
1174 | update_policy_cpu(data, cpu_dev->id); | ||
1175 | unlock_policy_rwsem_write(cpu); | ||
1176 | pr_debug("%s: policy Kobject moved to cpu: %d from: %d\n", | ||
1177 | __func__, cpu_dev->id, cpu); | ||
1178 | } | 1214 | } |
1179 | 1215 | ||
1180 | /* If cpu is last user of policy, free policy */ | 1216 | /* If cpu is last user of policy, free policy */ |
1181 | if (cpus == 1) { | 1217 | if (cpus == 1) { |
1182 | if (cpufreq_driver->target) | 1218 | if (cpufreq_driver->target) { |
1183 | __cpufreq_governor(data, CPUFREQ_GOV_POLICY_EXIT); | 1219 | ret = __cpufreq_governor(policy, |
1184 | 1220 | CPUFREQ_GOV_POLICY_EXIT); | |
1185 | lock_policy_rwsem_read(cpu); | 1221 | if (ret) { |
1186 | kobj = &data->kobj; | 1222 | pr_err("%s: Failed to exit governor\n", |
1187 | cmp = &data->kobj_unregister; | 1223 | __func__); |
1188 | unlock_policy_rwsem_read(cpu); | 1224 | return ret; |
1189 | kobject_put(kobj); | 1225 | } |
1190 | 1226 | } | |
1191 | /* we need to make sure that the underlying kobj is actually | 1227 | |
1192 | * not referenced anymore by anybody before we proceed with | 1228 | if (!frozen) { |
1193 | * unloading. | 1229 | lock_policy_rwsem_read(cpu); |
1194 | */ | 1230 | kobj = &policy->kobj; |
1195 | pr_debug("waiting for dropping of refcount\n"); | 1231 | cmp = &policy->kobj_unregister; |
1196 | wait_for_completion(cmp); | 1232 | unlock_policy_rwsem_read(cpu); |
1197 | pr_debug("wait complete\n"); | 1233 | kobject_put(kobj); |
1234 | |||
1235 | /* | ||
1236 | * We need to make sure that the underlying kobj is | ||
1237 | * actually not referenced anymore by anybody before we | ||
1238 | * proceed with unloading. | ||
1239 | */ | ||
1240 | pr_debug("waiting for dropping of refcount\n"); | ||
1241 | wait_for_completion(cmp); | ||
1242 | pr_debug("wait complete\n"); | ||
1243 | } | ||
1198 | 1244 | ||
1245 | /* | ||
1246 | * Perform the ->exit() even during light-weight tear-down, | ||
1247 | * since this is a core component, and is essential for the | ||
1248 | * subsequent light-weight ->init() to succeed. | ||
1249 | */ | ||
1199 | if (cpufreq_driver->exit) | 1250 | if (cpufreq_driver->exit) |
1200 | cpufreq_driver->exit(data); | 1251 | cpufreq_driver->exit(policy); |
1201 | 1252 | ||
1202 | free_cpumask_var(data->related_cpus); | 1253 | /* Remove policy from list of active policies */ |
1203 | free_cpumask_var(data->cpus); | 1254 | write_lock_irqsave(&cpufreq_driver_lock, flags); |
1204 | kfree(data); | 1255 | list_del(&policy->policy_list); |
1256 | write_unlock_irqrestore(&cpufreq_driver_lock, flags); | ||
1257 | |||
1258 | if (!frozen) | ||
1259 | cpufreq_policy_free(policy); | ||
1205 | } else { | 1260 | } else { |
1206 | pr_debug("%s: removing link, cpu: %d\n", __func__, cpu); | ||
1207 | cpufreq_cpu_put(data); | ||
1208 | if (cpufreq_driver->target) { | 1261 | if (cpufreq_driver->target) { |
1209 | __cpufreq_governor(data, CPUFREQ_GOV_START); | 1262 | if ((ret = __cpufreq_governor(policy, CPUFREQ_GOV_START)) || |
1210 | __cpufreq_governor(data, CPUFREQ_GOV_LIMITS); | 1263 | (ret = __cpufreq_governor(policy, CPUFREQ_GOV_LIMITS))) { |
1264 | pr_err("%s: Failed to start governor\n", | ||
1265 | __func__); | ||
1266 | return ret; | ||
1267 | } | ||
1211 | } | 1268 | } |
1212 | } | 1269 | } |
1213 | 1270 | ||
1214 | per_cpu(cpufreq_policy_cpu, cpu) = -1; | 1271 | per_cpu(cpufreq_cpu_data, cpu) = NULL; |
1215 | return 0; | 1272 | return 0; |
1216 | } | 1273 | } |
1217 | 1274 | ||
@@ -1223,7 +1280,7 @@ static int cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif) | |||
1223 | if (cpu_is_offline(cpu)) | 1280 | if (cpu_is_offline(cpu)) |
1224 | return 0; | 1281 | return 0; |
1225 | 1282 | ||
1226 | retval = __cpufreq_remove_dev(dev, sif); | 1283 | retval = __cpufreq_remove_dev(dev, sif, false); |
1227 | return retval; | 1284 | return retval; |
1228 | } | 1285 | } |
1229 | 1286 | ||
@@ -1344,10 +1401,9 @@ static unsigned int __cpufreq_get(unsigned int cpu) | |||
1344 | unsigned int cpufreq_get(unsigned int cpu) | 1401 | unsigned int cpufreq_get(unsigned int cpu) |
1345 | { | 1402 | { |
1346 | unsigned int ret_freq = 0; | 1403 | unsigned int ret_freq = 0; |
1347 | struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); | ||
1348 | 1404 | ||
1349 | if (!policy) | 1405 | if (!down_read_trylock(&cpufreq_rwsem)) |
1350 | goto out; | 1406 | return 0; |
1351 | 1407 | ||
1352 | if (unlikely(lock_policy_rwsem_read(cpu))) | 1408 | if (unlikely(lock_policy_rwsem_read(cpu))) |
1353 | goto out_policy; | 1409 | goto out_policy; |
@@ -1357,8 +1413,8 @@ unsigned int cpufreq_get(unsigned int cpu) | |||
1357 | unlock_policy_rwsem_read(cpu); | 1413 | unlock_policy_rwsem_read(cpu); |
1358 | 1414 | ||
1359 | out_policy: | 1415 | out_policy: |
1360 | cpufreq_cpu_put(policy); | 1416 | up_read(&cpufreq_rwsem); |
1361 | out: | 1417 | |
1362 | return ret_freq; | 1418 | return ret_freq; |
1363 | } | 1419 | } |
1364 | EXPORT_SYMBOL(cpufreq_get); | 1420 | EXPORT_SYMBOL(cpufreq_get); |
@@ -1381,23 +1437,23 @@ static int cpufreq_bp_suspend(void) | |||
1381 | int ret = 0; | 1437 | int ret = 0; |
1382 | 1438 | ||
1383 | int cpu = smp_processor_id(); | 1439 | int cpu = smp_processor_id(); |
1384 | struct cpufreq_policy *cpu_policy; | 1440 | struct cpufreq_policy *policy; |
1385 | 1441 | ||
1386 | pr_debug("suspending cpu %u\n", cpu); | 1442 | pr_debug("suspending cpu %u\n", cpu); |
1387 | 1443 | ||
1388 | /* If there's no policy for the boot CPU, we have nothing to do. */ | 1444 | /* If there's no policy for the boot CPU, we have nothing to do. */ |
1389 | cpu_policy = cpufreq_cpu_get(cpu); | 1445 | policy = cpufreq_cpu_get(cpu); |
1390 | if (!cpu_policy) | 1446 | if (!policy) |
1391 | return 0; | 1447 | return 0; |
1392 | 1448 | ||
1393 | if (cpufreq_driver->suspend) { | 1449 | if (cpufreq_driver->suspend) { |
1394 | ret = cpufreq_driver->suspend(cpu_policy); | 1450 | ret = cpufreq_driver->suspend(policy); |
1395 | if (ret) | 1451 | if (ret) |
1396 | printk(KERN_ERR "cpufreq: suspend failed in ->suspend " | 1452 | printk(KERN_ERR "cpufreq: suspend failed in ->suspend " |
1397 | "step on CPU %u\n", cpu_policy->cpu); | 1453 | "step on CPU %u\n", policy->cpu); |
1398 | } | 1454 | } |
1399 | 1455 | ||
1400 | cpufreq_cpu_put(cpu_policy); | 1456 | cpufreq_cpu_put(policy); |
1401 | return ret; | 1457 | return ret; |
1402 | } | 1458 | } |
1403 | 1459 | ||
@@ -1419,28 +1475,28 @@ static void cpufreq_bp_resume(void) | |||
1419 | int ret = 0; | 1475 | int ret = 0; |
1420 | 1476 | ||
1421 | int cpu = smp_processor_id(); | 1477 | int cpu = smp_processor_id(); |
1422 | struct cpufreq_policy *cpu_policy; | 1478 | struct cpufreq_policy *policy; |
1423 | 1479 | ||
1424 | pr_debug("resuming cpu %u\n", cpu); | 1480 | pr_debug("resuming cpu %u\n", cpu); |
1425 | 1481 | ||
1426 | /* If there's no policy for the boot CPU, we have nothing to do. */ | 1482 | /* If there's no policy for the boot CPU, we have nothing to do. */ |
1427 | cpu_policy = cpufreq_cpu_get(cpu); | 1483 | policy = cpufreq_cpu_get(cpu); |
1428 | if (!cpu_policy) | 1484 | if (!policy) |
1429 | return; | 1485 | return; |
1430 | 1486 | ||
1431 | if (cpufreq_driver->resume) { | 1487 | if (cpufreq_driver->resume) { |
1432 | ret = cpufreq_driver->resume(cpu_policy); | 1488 | ret = cpufreq_driver->resume(policy); |
1433 | if (ret) { | 1489 | if (ret) { |
1434 | printk(KERN_ERR "cpufreq: resume failed in ->resume " | 1490 | printk(KERN_ERR "cpufreq: resume failed in ->resume " |
1435 | "step on CPU %u\n", cpu_policy->cpu); | 1491 | "step on CPU %u\n", policy->cpu); |
1436 | goto fail; | 1492 | goto fail; |
1437 | } | 1493 | } |
1438 | } | 1494 | } |
1439 | 1495 | ||
1440 | schedule_work(&cpu_policy->update); | 1496 | schedule_work(&policy->update); |
1441 | 1497 | ||
1442 | fail: | 1498 | fail: |
1443 | cpufreq_cpu_put(cpu_policy); | 1499 | cpufreq_cpu_put(policy); |
1444 | } | 1500 | } |
1445 | 1501 | ||
1446 | static struct syscore_ops cpufreq_syscore_ops = { | 1502 | static struct syscore_ops cpufreq_syscore_ops = { |
@@ -1594,18 +1650,6 @@ fail: | |||
1594 | } | 1650 | } |
1595 | EXPORT_SYMBOL_GPL(cpufreq_driver_target); | 1651 | EXPORT_SYMBOL_GPL(cpufreq_driver_target); |
1596 | 1652 | ||
1597 | int __cpufreq_driver_getavg(struct cpufreq_policy *policy, unsigned int cpu) | ||
1598 | { | ||
1599 | if (cpufreq_disabled()) | ||
1600 | return 0; | ||
1601 | |||
1602 | if (!cpufreq_driver->getavg) | ||
1603 | return 0; | ||
1604 | |||
1605 | return cpufreq_driver->getavg(policy, cpu); | ||
1606 | } | ||
1607 | EXPORT_SYMBOL_GPL(__cpufreq_driver_getavg); | ||
1608 | |||
1609 | /* | 1653 | /* |
1610 | * when "event" is CPUFREQ_GOV_LIMITS | 1654 | * when "event" is CPUFREQ_GOV_LIMITS |
1611 | */ | 1655 | */ |
@@ -1640,8 +1684,9 @@ static int __cpufreq_governor(struct cpufreq_policy *policy, | |||
1640 | } | 1684 | } |
1641 | } | 1685 | } |
1642 | 1686 | ||
1643 | if (!try_module_get(policy->governor->owner)) | 1687 | if (event == CPUFREQ_GOV_POLICY_INIT) |
1644 | return -EINVAL; | 1688 | if (!try_module_get(policy->governor->owner)) |
1689 | return -EINVAL; | ||
1645 | 1690 | ||
1646 | pr_debug("__cpufreq_governor for CPU %u, event %u\n", | 1691 | pr_debug("__cpufreq_governor for CPU %u, event %u\n", |
1647 | policy->cpu, event); | 1692 | policy->cpu, event); |
@@ -1677,11 +1722,8 @@ static int __cpufreq_governor(struct cpufreq_policy *policy, | |||
1677 | mutex_unlock(&cpufreq_governor_lock); | 1722 | mutex_unlock(&cpufreq_governor_lock); |
1678 | } | 1723 | } |
1679 | 1724 | ||
1680 | /* we keep one module reference alive for | 1725 | if (((event == CPUFREQ_GOV_POLICY_INIT) && ret) || |
1681 | each CPU governed by this CPU */ | 1726 | ((event == CPUFREQ_GOV_POLICY_EXIT) && !ret)) |
1682 | if ((event != CPUFREQ_GOV_START) || ret) | ||
1683 | module_put(policy->governor->owner); | ||
1684 | if ((event == CPUFREQ_GOV_STOP) && !ret) | ||
1685 | module_put(policy->governor->owner); | 1727 | module_put(policy->governor->owner); |
1686 | 1728 | ||
1687 | return ret; | 1729 | return ret; |
@@ -1761,7 +1803,7 @@ int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu) | |||
1761 | if (!cpu_policy) | 1803 | if (!cpu_policy) |
1762 | return -EINVAL; | 1804 | return -EINVAL; |
1763 | 1805 | ||
1764 | memcpy(policy, cpu_policy, sizeof(struct cpufreq_policy)); | 1806 | memcpy(policy, cpu_policy, sizeof(*policy)); |
1765 | 1807 | ||
1766 | cpufreq_cpu_put(cpu_policy); | 1808 | cpufreq_cpu_put(cpu_policy); |
1767 | return 0; | 1809 | return 0; |
@@ -1772,95 +1814,94 @@ EXPORT_SYMBOL(cpufreq_get_policy); | |||
1772 | * data : current policy. | 1814 | * data : current policy. |
1773 | * policy : policy to be set. | 1815 | * policy : policy to be set. |
1774 | */ | 1816 | */ |
1775 | static int __cpufreq_set_policy(struct cpufreq_policy *data, | 1817 | static int __cpufreq_set_policy(struct cpufreq_policy *policy, |
1776 | struct cpufreq_policy *policy) | 1818 | struct cpufreq_policy *new_policy) |
1777 | { | 1819 | { |
1778 | int ret = 0, failed = 1; | 1820 | int ret = 0, failed = 1; |
1779 | 1821 | ||
1780 | pr_debug("setting new policy for CPU %u: %u - %u kHz\n", policy->cpu, | 1822 | pr_debug("setting new policy for CPU %u: %u - %u kHz\n", new_policy->cpu, |
1781 | policy->min, policy->max); | 1823 | new_policy->min, new_policy->max); |
1782 | 1824 | ||
1783 | memcpy(&policy->cpuinfo, &data->cpuinfo, | 1825 | memcpy(&new_policy->cpuinfo, &policy->cpuinfo, sizeof(policy->cpuinfo)); |
1784 | sizeof(struct cpufreq_cpuinfo)); | ||
1785 | 1826 | ||
1786 | if (policy->min > data->max || policy->max < data->min) { | 1827 | if (new_policy->min > policy->max || new_policy->max < policy->min) { |
1787 | ret = -EINVAL; | 1828 | ret = -EINVAL; |
1788 | goto error_out; | 1829 | goto error_out; |
1789 | } | 1830 | } |
1790 | 1831 | ||
1791 | /* verify the cpu speed can be set within this limit */ | 1832 | /* verify the cpu speed can be set within this limit */ |
1792 | ret = cpufreq_driver->verify(policy); | 1833 | ret = cpufreq_driver->verify(new_policy); |
1793 | if (ret) | 1834 | if (ret) |
1794 | goto error_out; | 1835 | goto error_out; |
1795 | 1836 | ||
1796 | /* adjust if necessary - all reasons */ | 1837 | /* adjust if necessary - all reasons */ |
1797 | blocking_notifier_call_chain(&cpufreq_policy_notifier_list, | 1838 | blocking_notifier_call_chain(&cpufreq_policy_notifier_list, |
1798 | CPUFREQ_ADJUST, policy); | 1839 | CPUFREQ_ADJUST, new_policy); |
1799 | 1840 | ||
1800 | /* adjust if necessary - hardware incompatibility*/ | 1841 | /* adjust if necessary - hardware incompatibility*/ |
1801 | blocking_notifier_call_chain(&cpufreq_policy_notifier_list, | 1842 | blocking_notifier_call_chain(&cpufreq_policy_notifier_list, |
1802 | CPUFREQ_INCOMPATIBLE, policy); | 1843 | CPUFREQ_INCOMPATIBLE, new_policy); |
1803 | 1844 | ||
1804 | /* | 1845 | /* |
1805 | * verify the cpu speed can be set within this limit, which might be | 1846 | * verify the cpu speed can be set within this limit, which might be |
1806 | * different to the first one | 1847 | * different to the first one |
1807 | */ | 1848 | */ |
1808 | ret = cpufreq_driver->verify(policy); | 1849 | ret = cpufreq_driver->verify(new_policy); |
1809 | if (ret) | 1850 | if (ret) |
1810 | goto error_out; | 1851 | goto error_out; |
1811 | 1852 | ||
1812 | /* notification of the new policy */ | 1853 | /* notification of the new policy */ |
1813 | blocking_notifier_call_chain(&cpufreq_policy_notifier_list, | 1854 | blocking_notifier_call_chain(&cpufreq_policy_notifier_list, |
1814 | CPUFREQ_NOTIFY, policy); | 1855 | CPUFREQ_NOTIFY, new_policy); |
1815 | 1856 | ||
1816 | data->min = policy->min; | 1857 | policy->min = new_policy->min; |
1817 | data->max = policy->max; | 1858 | policy->max = new_policy->max; |
1818 | 1859 | ||
1819 | pr_debug("new min and max freqs are %u - %u kHz\n", | 1860 | pr_debug("new min and max freqs are %u - %u kHz\n", |
1820 | data->min, data->max); | 1861 | policy->min, policy->max); |
1821 | 1862 | ||
1822 | if (cpufreq_driver->setpolicy) { | 1863 | if (cpufreq_driver->setpolicy) { |
1823 | data->policy = policy->policy; | 1864 | policy->policy = new_policy->policy; |
1824 | pr_debug("setting range\n"); | 1865 | pr_debug("setting range\n"); |
1825 | ret = cpufreq_driver->setpolicy(policy); | 1866 | ret = cpufreq_driver->setpolicy(new_policy); |
1826 | } else { | 1867 | } else { |
1827 | if (policy->governor != data->governor) { | 1868 | if (new_policy->governor != policy->governor) { |
1828 | /* save old, working values */ | 1869 | /* save old, working values */ |
1829 | struct cpufreq_governor *old_gov = data->governor; | 1870 | struct cpufreq_governor *old_gov = policy->governor; |
1830 | 1871 | ||
1831 | pr_debug("governor switch\n"); | 1872 | pr_debug("governor switch\n"); |
1832 | 1873 | ||
1833 | /* end old governor */ | 1874 | /* end old governor */ |
1834 | if (data->governor) { | 1875 | if (policy->governor) { |
1835 | __cpufreq_governor(data, CPUFREQ_GOV_STOP); | 1876 | __cpufreq_governor(policy, CPUFREQ_GOV_STOP); |
1836 | unlock_policy_rwsem_write(policy->cpu); | 1877 | unlock_policy_rwsem_write(new_policy->cpu); |
1837 | __cpufreq_governor(data, | 1878 | __cpufreq_governor(policy, |
1838 | CPUFREQ_GOV_POLICY_EXIT); | 1879 | CPUFREQ_GOV_POLICY_EXIT); |
1839 | lock_policy_rwsem_write(policy->cpu); | 1880 | lock_policy_rwsem_write(new_policy->cpu); |
1840 | } | 1881 | } |
1841 | 1882 | ||
1842 | /* start new governor */ | 1883 | /* start new governor */ |
1843 | data->governor = policy->governor; | 1884 | policy->governor = new_policy->governor; |
1844 | if (!__cpufreq_governor(data, CPUFREQ_GOV_POLICY_INIT)) { | 1885 | if (!__cpufreq_governor(policy, CPUFREQ_GOV_POLICY_INIT)) { |
1845 | if (!__cpufreq_governor(data, CPUFREQ_GOV_START)) { | 1886 | if (!__cpufreq_governor(policy, CPUFREQ_GOV_START)) { |
1846 | failed = 0; | 1887 | failed = 0; |
1847 | } else { | 1888 | } else { |
1848 | unlock_policy_rwsem_write(policy->cpu); | 1889 | unlock_policy_rwsem_write(new_policy->cpu); |
1849 | __cpufreq_governor(data, | 1890 | __cpufreq_governor(policy, |
1850 | CPUFREQ_GOV_POLICY_EXIT); | 1891 | CPUFREQ_GOV_POLICY_EXIT); |
1851 | lock_policy_rwsem_write(policy->cpu); | 1892 | lock_policy_rwsem_write(new_policy->cpu); |
1852 | } | 1893 | } |
1853 | } | 1894 | } |
1854 | 1895 | ||
1855 | if (failed) { | 1896 | if (failed) { |
1856 | /* new governor failed, so re-start old one */ | 1897 | /* new governor failed, so re-start old one */ |
1857 | pr_debug("starting governor %s failed\n", | 1898 | pr_debug("starting governor %s failed\n", |
1858 | data->governor->name); | 1899 | policy->governor->name); |
1859 | if (old_gov) { | 1900 | if (old_gov) { |
1860 | data->governor = old_gov; | 1901 | policy->governor = old_gov; |
1861 | __cpufreq_governor(data, | 1902 | __cpufreq_governor(policy, |
1862 | CPUFREQ_GOV_POLICY_INIT); | 1903 | CPUFREQ_GOV_POLICY_INIT); |
1863 | __cpufreq_governor(data, | 1904 | __cpufreq_governor(policy, |
1864 | CPUFREQ_GOV_START); | 1905 | CPUFREQ_GOV_START); |
1865 | } | 1906 | } |
1866 | ret = -EINVAL; | 1907 | ret = -EINVAL; |
@@ -1869,7 +1910,7 @@ static int __cpufreq_set_policy(struct cpufreq_policy *data, | |||
1869 | /* might be a policy change, too, so fall through */ | 1910 | /* might be a policy change, too, so fall through */ |
1870 | } | 1911 | } |
1871 | pr_debug("governor: change or update limits\n"); | 1912 | pr_debug("governor: change or update limits\n"); |
1872 | __cpufreq_governor(data, CPUFREQ_GOV_LIMITS); | 1913 | ret = __cpufreq_governor(policy, CPUFREQ_GOV_LIMITS); |
1873 | } | 1914 | } |
1874 | 1915 | ||
1875 | error_out: | 1916 | error_out: |
@@ -1885,11 +1926,11 @@ error_out: | |||
1885 | */ | 1926 | */ |
1886 | int cpufreq_update_policy(unsigned int cpu) | 1927 | int cpufreq_update_policy(unsigned int cpu) |
1887 | { | 1928 | { |
1888 | struct cpufreq_policy *data = cpufreq_cpu_get(cpu); | 1929 | struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); |
1889 | struct cpufreq_policy policy; | 1930 | struct cpufreq_policy new_policy; |
1890 | int ret; | 1931 | int ret; |
1891 | 1932 | ||
1892 | if (!data) { | 1933 | if (!policy) { |
1893 | ret = -ENODEV; | 1934 | ret = -ENODEV; |
1894 | goto no_policy; | 1935 | goto no_policy; |
1895 | } | 1936 | } |
@@ -1900,34 +1941,34 @@ int cpufreq_update_policy(unsigned int cpu) | |||
1900 | } | 1941 | } |
1901 | 1942 | ||
1902 | pr_debug("updating policy for CPU %u\n", cpu); | 1943 | pr_debug("updating policy for CPU %u\n", cpu); |
1903 | memcpy(&policy, data, sizeof(struct cpufreq_policy)); | 1944 | memcpy(&new_policy, policy, sizeof(*policy)); |
1904 | policy.min = data->user_policy.min; | 1945 | new_policy.min = policy->user_policy.min; |
1905 | policy.max = data->user_policy.max; | 1946 | new_policy.max = policy->user_policy.max; |
1906 | policy.policy = data->user_policy.policy; | 1947 | new_policy.policy = policy->user_policy.policy; |
1907 | policy.governor = data->user_policy.governor; | 1948 | new_policy.governor = policy->user_policy.governor; |
1908 | 1949 | ||
1909 | /* | 1950 | /* |
1910 | * BIOS might change freq behind our back | 1951 | * BIOS might change freq behind our back |
1911 | * -> ask driver for current freq and notify governors about a change | 1952 | * -> ask driver for current freq and notify governors about a change |
1912 | */ | 1953 | */ |
1913 | if (cpufreq_driver->get) { | 1954 | if (cpufreq_driver->get) { |
1914 | policy.cur = cpufreq_driver->get(cpu); | 1955 | new_policy.cur = cpufreq_driver->get(cpu); |
1915 | if (!data->cur) { | 1956 | if (!policy->cur) { |
1916 | pr_debug("Driver did not initialize current freq"); | 1957 | pr_debug("Driver did not initialize current freq"); |
1917 | data->cur = policy.cur; | 1958 | policy->cur = new_policy.cur; |
1918 | } else { | 1959 | } else { |
1919 | if (data->cur != policy.cur && cpufreq_driver->target) | 1960 | if (policy->cur != new_policy.cur && cpufreq_driver->target) |
1920 | cpufreq_out_of_sync(cpu, data->cur, | 1961 | cpufreq_out_of_sync(cpu, policy->cur, |
1921 | policy.cur); | 1962 | new_policy.cur); |
1922 | } | 1963 | } |
1923 | } | 1964 | } |
1924 | 1965 | ||
1925 | ret = __cpufreq_set_policy(data, &policy); | 1966 | ret = __cpufreq_set_policy(policy, &new_policy); |
1926 | 1967 | ||
1927 | unlock_policy_rwsem_write(cpu); | 1968 | unlock_policy_rwsem_write(cpu); |
1928 | 1969 | ||
1929 | fail: | 1970 | fail: |
1930 | cpufreq_cpu_put(data); | 1971 | cpufreq_cpu_put(policy); |
1931 | no_policy: | 1972 | no_policy: |
1932 | return ret; | 1973 | return ret; |
1933 | } | 1974 | } |
@@ -1938,21 +1979,26 @@ static int cpufreq_cpu_callback(struct notifier_block *nfb, | |||
1938 | { | 1979 | { |
1939 | unsigned int cpu = (unsigned long)hcpu; | 1980 | unsigned int cpu = (unsigned long)hcpu; |
1940 | struct device *dev; | 1981 | struct device *dev; |
1982 | bool frozen = false; | ||
1941 | 1983 | ||
1942 | dev = get_cpu_device(cpu); | 1984 | dev = get_cpu_device(cpu); |
1943 | if (dev) { | 1985 | if (dev) { |
1944 | switch (action) { | 1986 | |
1987 | if (action & CPU_TASKS_FROZEN) | ||
1988 | frozen = true; | ||
1989 | |||
1990 | switch (action & ~CPU_TASKS_FROZEN) { | ||
1945 | case CPU_ONLINE: | 1991 | case CPU_ONLINE: |
1946 | case CPU_ONLINE_FROZEN: | 1992 | __cpufreq_add_dev(dev, NULL, frozen); |
1947 | cpufreq_add_dev(dev, NULL); | 1993 | cpufreq_update_policy(cpu); |
1948 | break; | 1994 | break; |
1995 | |||
1949 | case CPU_DOWN_PREPARE: | 1996 | case CPU_DOWN_PREPARE: |
1950 | case CPU_DOWN_PREPARE_FROZEN: | 1997 | __cpufreq_remove_dev(dev, NULL, frozen); |
1951 | __cpufreq_remove_dev(dev, NULL); | ||
1952 | break; | 1998 | break; |
1999 | |||
1953 | case CPU_DOWN_FAILED: | 2000 | case CPU_DOWN_FAILED: |
1954 | case CPU_DOWN_FAILED_FROZEN: | 2001 | __cpufreq_add_dev(dev, NULL, frozen); |
1955 | cpufreq_add_dev(dev, NULL); | ||
1956 | break; | 2002 | break; |
1957 | } | 2003 | } |
1958 | } | 2004 | } |
@@ -2059,9 +2105,13 @@ int cpufreq_unregister_driver(struct cpufreq_driver *driver) | |||
2059 | subsys_interface_unregister(&cpufreq_interface); | 2105 | subsys_interface_unregister(&cpufreq_interface); |
2060 | unregister_hotcpu_notifier(&cpufreq_cpu_notifier); | 2106 | unregister_hotcpu_notifier(&cpufreq_cpu_notifier); |
2061 | 2107 | ||
2108 | down_write(&cpufreq_rwsem); | ||
2062 | write_lock_irqsave(&cpufreq_driver_lock, flags); | 2109 | write_lock_irqsave(&cpufreq_driver_lock, flags); |
2110 | |||
2063 | cpufreq_driver = NULL; | 2111 | cpufreq_driver = NULL; |
2112 | |||
2064 | write_unlock_irqrestore(&cpufreq_driver_lock, flags); | 2113 | write_unlock_irqrestore(&cpufreq_driver_lock, flags); |
2114 | up_write(&cpufreq_rwsem); | ||
2065 | 2115 | ||
2066 | return 0; | 2116 | return 0; |
2067 | } | 2117 | } |
@@ -2074,10 +2124,8 @@ static int __init cpufreq_core_init(void) | |||
2074 | if (cpufreq_disabled()) | 2124 | if (cpufreq_disabled()) |
2075 | return -ENODEV; | 2125 | return -ENODEV; |
2076 | 2126 | ||
2077 | for_each_possible_cpu(cpu) { | 2127 | for_each_possible_cpu(cpu) |
2078 | per_cpu(cpufreq_policy_cpu, cpu) = -1; | ||
2079 | init_rwsem(&per_cpu(cpu_policy_rwsem, cpu)); | 2128 | init_rwsem(&per_cpu(cpu_policy_rwsem, cpu)); |
2080 | } | ||
2081 | 2129 | ||
2082 | cpufreq_global_kobject = kobject_create(); | 2130 | cpufreq_global_kobject = kobject_create(); |
2083 | BUG_ON(!cpufreq_global_kobject); | 2131 | BUG_ON(!cpufreq_global_kobject); |
diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c index f97cb3d8c5a2..7f67a75b3c3c 100644 --- a/drivers/cpufreq/cpufreq_conservative.c +++ b/drivers/cpufreq/cpufreq_conservative.c | |||
@@ -11,19 +11,7 @@ | |||
11 | * published by the Free Software Foundation. | 11 | * published by the Free Software Foundation. |
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include <linux/cpufreq.h> | ||
15 | #include <linux/init.h> | ||
16 | #include <linux/kernel.h> | ||
17 | #include <linux/kernel_stat.h> | ||
18 | #include <linux/kobject.h> | ||
19 | #include <linux/module.h> | ||
20 | #include <linux/mutex.h> | ||
21 | #include <linux/notifier.h> | ||
22 | #include <linux/percpu-defs.h> | ||
23 | #include <linux/slab.h> | 14 | #include <linux/slab.h> |
24 | #include <linux/sysfs.h> | ||
25 | #include <linux/types.h> | ||
26 | |||
27 | #include "cpufreq_governor.h" | 15 | #include "cpufreq_governor.h" |
28 | 16 | ||
29 | /* Conservative governor macros */ | 17 | /* Conservative governor macros */ |
@@ -329,7 +317,7 @@ static int cs_init(struct dbs_data *dbs_data) | |||
329 | { | 317 | { |
330 | struct cs_dbs_tuners *tuners; | 318 | struct cs_dbs_tuners *tuners; |
331 | 319 | ||
332 | tuners = kzalloc(sizeof(struct cs_dbs_tuners), GFP_KERNEL); | 320 | tuners = kzalloc(sizeof(*tuners), GFP_KERNEL); |
333 | if (!tuners) { | 321 | if (!tuners) { |
334 | pr_err("%s: kzalloc failed\n", __func__); | 322 | pr_err("%s: kzalloc failed\n", __func__); |
335 | return -ENOMEM; | 323 | return -ENOMEM; |
diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c index e59afaa9da23..87427360c77f 100644 --- a/drivers/cpufreq/cpufreq_governor.c +++ b/drivers/cpufreq/cpufreq_governor.c | |||
@@ -16,15 +16,9 @@ | |||
16 | 16 | ||
17 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | 17 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
18 | 18 | ||
19 | #include <asm/cputime.h> | ||
20 | #include <linux/cpufreq.h> | ||
21 | #include <linux/cpumask.h> | ||
22 | #include <linux/export.h> | 19 | #include <linux/export.h> |
23 | #include <linux/kernel_stat.h> | 20 | #include <linux/kernel_stat.h> |
24 | #include <linux/mutex.h> | ||
25 | #include <linux/slab.h> | 21 | #include <linux/slab.h> |
26 | #include <linux/types.h> | ||
27 | #include <linux/workqueue.h> | ||
28 | 22 | ||
29 | #include "cpufreq_governor.h" | 23 | #include "cpufreq_governor.h" |
30 | 24 | ||
@@ -53,7 +47,7 @@ void dbs_check_cpu(struct dbs_data *dbs_data, int cpu) | |||
53 | 47 | ||
54 | policy = cdbs->cur_policy; | 48 | policy = cdbs->cur_policy; |
55 | 49 | ||
56 | /* Get Absolute Load (in terms of freq for ondemand gov) */ | 50 | /* Get Absolute Load */ |
57 | for_each_cpu(j, policy->cpus) { | 51 | for_each_cpu(j, policy->cpus) { |
58 | struct cpu_dbs_common_info *j_cdbs; | 52 | struct cpu_dbs_common_info *j_cdbs; |
59 | u64 cur_wall_time, cur_idle_time; | 53 | u64 cur_wall_time, cur_idle_time; |
@@ -104,14 +98,6 @@ void dbs_check_cpu(struct dbs_data *dbs_data, int cpu) | |||
104 | 98 | ||
105 | load = 100 * (wall_time - idle_time) / wall_time; | 99 | load = 100 * (wall_time - idle_time) / wall_time; |
106 | 100 | ||
107 | if (dbs_data->cdata->governor == GOV_ONDEMAND) { | ||
108 | int freq_avg = __cpufreq_driver_getavg(policy, j); | ||
109 | if (freq_avg <= 0) | ||
110 | freq_avg = policy->cur; | ||
111 | |||
112 | load *= freq_avg; | ||
113 | } | ||
114 | |||
115 | if (load > max_load) | 101 | if (load > max_load) |
116 | max_load = load; | 102 | max_load = load; |
117 | } | 103 | } |
diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h index d5f12b4b11b8..a02d78b25898 100644 --- a/drivers/cpufreq/cpufreq_governor.h +++ b/drivers/cpufreq/cpufreq_governor.h | |||
@@ -18,10 +18,9 @@ | |||
18 | #define _CPUFREQ_GOVERNOR_H | 18 | #define _CPUFREQ_GOVERNOR_H |
19 | 19 | ||
20 | #include <linux/cpufreq.h> | 20 | #include <linux/cpufreq.h> |
21 | #include <linux/kobject.h> | 21 | #include <linux/kernel_stat.h> |
22 | #include <linux/module.h> | ||
22 | #include <linux/mutex.h> | 23 | #include <linux/mutex.h> |
23 | #include <linux/workqueue.h> | ||
24 | #include <linux/sysfs.h> | ||
25 | 24 | ||
26 | /* | 25 | /* |
27 | * The polling frequency depends on the capability of the processor. Default | 26 | * The polling frequency depends on the capability of the processor. Default |
@@ -169,7 +168,6 @@ struct od_dbs_tuners { | |||
169 | unsigned int sampling_rate; | 168 | unsigned int sampling_rate; |
170 | unsigned int sampling_down_factor; | 169 | unsigned int sampling_down_factor; |
171 | unsigned int up_threshold; | 170 | unsigned int up_threshold; |
172 | unsigned int adj_up_threshold; | ||
173 | unsigned int powersave_bias; | 171 | unsigned int powersave_bias; |
174 | unsigned int io_is_busy; | 172 | unsigned int io_is_busy; |
175 | }; | 173 | }; |
@@ -223,7 +221,7 @@ struct od_ops { | |||
223 | void (*powersave_bias_init_cpu)(int cpu); | 221 | void (*powersave_bias_init_cpu)(int cpu); |
224 | unsigned int (*powersave_bias_target)(struct cpufreq_policy *policy, | 222 | unsigned int (*powersave_bias_target)(struct cpufreq_policy *policy, |
225 | unsigned int freq_next, unsigned int relation); | 223 | unsigned int freq_next, unsigned int relation); |
226 | void (*freq_increase)(struct cpufreq_policy *p, unsigned int freq); | 224 | void (*freq_increase)(struct cpufreq_policy *policy, unsigned int freq); |
227 | }; | 225 | }; |
228 | 226 | ||
229 | struct cs_ops { | 227 | struct cs_ops { |
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c index c087347d6688..87f3305e80a6 100644 --- a/drivers/cpufreq/cpufreq_ondemand.c +++ b/drivers/cpufreq/cpufreq_ondemand.c | |||
@@ -12,28 +12,16 @@ | |||
12 | 12 | ||
13 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | 13 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
14 | 14 | ||
15 | #include <linux/cpufreq.h> | 15 | #include <linux/cpu.h> |
16 | #include <linux/init.h> | ||
17 | #include <linux/kernel.h> | ||
18 | #include <linux/kernel_stat.h> | ||
19 | #include <linux/kobject.h> | ||
20 | #include <linux/module.h> | ||
21 | #include <linux/mutex.h> | ||
22 | #include <linux/percpu-defs.h> | 16 | #include <linux/percpu-defs.h> |
23 | #include <linux/slab.h> | 17 | #include <linux/slab.h> |
24 | #include <linux/sysfs.h> | ||
25 | #include <linux/tick.h> | 18 | #include <linux/tick.h> |
26 | #include <linux/types.h> | ||
27 | #include <linux/cpu.h> | ||
28 | |||
29 | #include "cpufreq_governor.h" | 19 | #include "cpufreq_governor.h" |
30 | 20 | ||
31 | /* On-demand governor macros */ | 21 | /* On-demand governor macros */ |
32 | #define DEF_FREQUENCY_DOWN_DIFFERENTIAL (10) | ||
33 | #define DEF_FREQUENCY_UP_THRESHOLD (80) | 22 | #define DEF_FREQUENCY_UP_THRESHOLD (80) |
34 | #define DEF_SAMPLING_DOWN_FACTOR (1) | 23 | #define DEF_SAMPLING_DOWN_FACTOR (1) |
35 | #define MAX_SAMPLING_DOWN_FACTOR (100000) | 24 | #define MAX_SAMPLING_DOWN_FACTOR (100000) |
36 | #define MICRO_FREQUENCY_DOWN_DIFFERENTIAL (3) | ||
37 | #define MICRO_FREQUENCY_UP_THRESHOLD (95) | 25 | #define MICRO_FREQUENCY_UP_THRESHOLD (95) |
38 | #define MICRO_FREQUENCY_MIN_SAMPLE_RATE (10000) | 26 | #define MICRO_FREQUENCY_MIN_SAMPLE_RATE (10000) |
39 | #define MIN_FREQUENCY_UP_THRESHOLD (11) | 27 | #define MIN_FREQUENCY_UP_THRESHOLD (11) |
@@ -144,31 +132,27 @@ static void ondemand_powersave_bias_init(void) | |||
144 | } | 132 | } |
145 | } | 133 | } |
146 | 134 | ||
147 | static void dbs_freq_increase(struct cpufreq_policy *p, unsigned int freq) | 135 | static void dbs_freq_increase(struct cpufreq_policy *policy, unsigned int freq) |
148 | { | 136 | { |
149 | struct dbs_data *dbs_data = p->governor_data; | 137 | struct dbs_data *dbs_data = policy->governor_data; |
150 | struct od_dbs_tuners *od_tuners = dbs_data->tuners; | 138 | struct od_dbs_tuners *od_tuners = dbs_data->tuners; |
151 | 139 | ||
152 | if (od_tuners->powersave_bias) | 140 | if (od_tuners->powersave_bias) |
153 | freq = od_ops.powersave_bias_target(p, freq, | 141 | freq = od_ops.powersave_bias_target(policy, freq, |
154 | CPUFREQ_RELATION_H); | 142 | CPUFREQ_RELATION_H); |
155 | else if (p->cur == p->max) | 143 | else if (policy->cur == policy->max) |
156 | return; | 144 | return; |
157 | 145 | ||
158 | __cpufreq_driver_target(p, freq, od_tuners->powersave_bias ? | 146 | __cpufreq_driver_target(policy, freq, od_tuners->powersave_bias ? |
159 | CPUFREQ_RELATION_L : CPUFREQ_RELATION_H); | 147 | CPUFREQ_RELATION_L : CPUFREQ_RELATION_H); |
160 | } | 148 | } |
161 | 149 | ||
162 | /* | 150 | /* |
163 | * Every sampling_rate, we check, if current idle time is less than 20% | 151 | * Every sampling_rate, we check, if current idle time is less than 20% |
164 | * (default), then we try to increase frequency. Every sampling_rate, we look | 152 | * (default), then we try to increase frequency. Else, we adjust the frequency |
165 | * for the lowest frequency which can sustain the load while keeping idle time | 153 | * proportional to load. |
166 | * over 30%. If such a frequency exist, we try to decrease to this frequency. | ||
167 | * | ||
168 | * Any frequency increase takes it to the maximum frequency. Frequency reduction | ||
169 | * happens at minimum steps of 5% (default) of current frequency | ||
170 | */ | 154 | */ |
171 | static void od_check_cpu(int cpu, unsigned int load_freq) | 155 | static void od_check_cpu(int cpu, unsigned int load) |
172 | { | 156 | { |
173 | struct od_cpu_dbs_info_s *dbs_info = &per_cpu(od_cpu_dbs_info, cpu); | 157 | struct od_cpu_dbs_info_s *dbs_info = &per_cpu(od_cpu_dbs_info, cpu); |
174 | struct cpufreq_policy *policy = dbs_info->cdbs.cur_policy; | 158 | struct cpufreq_policy *policy = dbs_info->cdbs.cur_policy; |
@@ -178,29 +162,17 @@ static void od_check_cpu(int cpu, unsigned int load_freq) | |||
178 | dbs_info->freq_lo = 0; | 162 | dbs_info->freq_lo = 0; |
179 | 163 | ||
180 | /* Check for frequency increase */ | 164 | /* Check for frequency increase */ |
181 | if (load_freq > od_tuners->up_threshold * policy->cur) { | 165 | if (load > od_tuners->up_threshold) { |
182 | /* If switching to max speed, apply sampling_down_factor */ | 166 | /* If switching to max speed, apply sampling_down_factor */ |
183 | if (policy->cur < policy->max) | 167 | if (policy->cur < policy->max) |
184 | dbs_info->rate_mult = | 168 | dbs_info->rate_mult = |
185 | od_tuners->sampling_down_factor; | 169 | od_tuners->sampling_down_factor; |
186 | dbs_freq_increase(policy, policy->max); | 170 | dbs_freq_increase(policy, policy->max); |
187 | return; | 171 | return; |
188 | } | 172 | } else { |
189 | 173 | /* Calculate the next frequency proportional to load */ | |
190 | /* Check for frequency decrease */ | ||
191 | /* if we cannot reduce the frequency anymore, break out early */ | ||
192 | if (policy->cur == policy->min) | ||
193 | return; | ||
194 | |||
195 | /* | ||
196 | * The optimal frequency is the frequency that is the lowest that can | ||
197 | * support the current CPU usage without triggering the up policy. To be | ||
198 | * safe, we focus 10 points under the threshold. | ||
199 | */ | ||
200 | if (load_freq < od_tuners->adj_up_threshold | ||
201 | * policy->cur) { | ||
202 | unsigned int freq_next; | 174 | unsigned int freq_next; |
203 | freq_next = load_freq / od_tuners->adj_up_threshold; | 175 | freq_next = load * policy->cpuinfo.max_freq / 100; |
204 | 176 | ||
205 | /* No longer fully busy, reset rate_mult */ | 177 | /* No longer fully busy, reset rate_mult */ |
206 | dbs_info->rate_mult = 1; | 178 | dbs_info->rate_mult = 1; |
@@ -374,9 +346,6 @@ static ssize_t store_up_threshold(struct dbs_data *dbs_data, const char *buf, | |||
374 | input < MIN_FREQUENCY_UP_THRESHOLD) { | 346 | input < MIN_FREQUENCY_UP_THRESHOLD) { |
375 | return -EINVAL; | 347 | return -EINVAL; |
376 | } | 348 | } |
377 | /* Calculate the new adj_up_threshold */ | ||
378 | od_tuners->adj_up_threshold += input; | ||
379 | od_tuners->adj_up_threshold -= od_tuners->up_threshold; | ||
380 | 349 | ||
381 | od_tuners->up_threshold = input; | 350 | od_tuners->up_threshold = input; |
382 | return count; | 351 | return count; |
@@ -513,7 +482,7 @@ static int od_init(struct dbs_data *dbs_data) | |||
513 | u64 idle_time; | 482 | u64 idle_time; |
514 | int cpu; | 483 | int cpu; |
515 | 484 | ||
516 | tuners = kzalloc(sizeof(struct od_dbs_tuners), GFP_KERNEL); | 485 | tuners = kzalloc(sizeof(*tuners), GFP_KERNEL); |
517 | if (!tuners) { | 486 | if (!tuners) { |
518 | pr_err("%s: kzalloc failed\n", __func__); | 487 | pr_err("%s: kzalloc failed\n", __func__); |
519 | return -ENOMEM; | 488 | return -ENOMEM; |
@@ -525,8 +494,6 @@ static int od_init(struct dbs_data *dbs_data) | |||
525 | if (idle_time != -1ULL) { | 494 | if (idle_time != -1ULL) { |
526 | /* Idle micro accounting is supported. Use finer thresholds */ | 495 | /* Idle micro accounting is supported. Use finer thresholds */ |
527 | tuners->up_threshold = MICRO_FREQUENCY_UP_THRESHOLD; | 496 | tuners->up_threshold = MICRO_FREQUENCY_UP_THRESHOLD; |
528 | tuners->adj_up_threshold = MICRO_FREQUENCY_UP_THRESHOLD - | ||
529 | MICRO_FREQUENCY_DOWN_DIFFERENTIAL; | ||
530 | /* | 497 | /* |
531 | * In nohz/micro accounting case we set the minimum frequency | 498 | * In nohz/micro accounting case we set the minimum frequency |
532 | * not depending on HZ, but fixed (very low). The deferred | 499 | * not depending on HZ, but fixed (very low). The deferred |
@@ -535,8 +502,6 @@ static int od_init(struct dbs_data *dbs_data) | |||
535 | dbs_data->min_sampling_rate = MICRO_FREQUENCY_MIN_SAMPLE_RATE; | 502 | dbs_data->min_sampling_rate = MICRO_FREQUENCY_MIN_SAMPLE_RATE; |
536 | } else { | 503 | } else { |
537 | tuners->up_threshold = DEF_FREQUENCY_UP_THRESHOLD; | 504 | tuners->up_threshold = DEF_FREQUENCY_UP_THRESHOLD; |
538 | tuners->adj_up_threshold = DEF_FREQUENCY_UP_THRESHOLD - | ||
539 | DEF_FREQUENCY_DOWN_DIFFERENTIAL; | ||
540 | 505 | ||
541 | /* For correct statistics, we need 10 ticks for each measure */ | 506 | /* For correct statistics, we need 10 ticks for each measure */ |
542 | dbs_data->min_sampling_rate = MIN_SAMPLING_RATE_RATIO * | 507 | dbs_data->min_sampling_rate = MIN_SAMPLING_RATE_RATIO * |
diff --git a/drivers/cpufreq/cpufreq_performance.c b/drivers/cpufreq/cpufreq_performance.c index 9fef7d6e4e6a..cf117deb39b1 100644 --- a/drivers/cpufreq/cpufreq_performance.c +++ b/drivers/cpufreq/cpufreq_performance.c | |||
@@ -12,10 +12,9 @@ | |||
12 | 12 | ||
13 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | 13 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
14 | 14 | ||
15 | #include <linux/kernel.h> | ||
16 | #include <linux/module.h> | ||
17 | #include <linux/cpufreq.h> | 15 | #include <linux/cpufreq.h> |
18 | #include <linux/init.h> | 16 | #include <linux/init.h> |
17 | #include <linux/module.h> | ||
19 | 18 | ||
20 | static int cpufreq_governor_performance(struct cpufreq_policy *policy, | 19 | static int cpufreq_governor_performance(struct cpufreq_policy *policy, |
21 | unsigned int event) | 20 | unsigned int event) |
diff --git a/drivers/cpufreq/cpufreq_powersave.c b/drivers/cpufreq/cpufreq_powersave.c index 32109a14f5dc..e3b874c235ea 100644 --- a/drivers/cpufreq/cpufreq_powersave.c +++ b/drivers/cpufreq/cpufreq_powersave.c | |||
@@ -12,10 +12,9 @@ | |||
12 | 12 | ||
13 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | 13 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
14 | 14 | ||
15 | #include <linux/kernel.h> | ||
16 | #include <linux/module.h> | ||
17 | #include <linux/cpufreq.h> | 15 | #include <linux/cpufreq.h> |
18 | #include <linux/init.h> | 16 | #include <linux/init.h> |
17 | #include <linux/module.h> | ||
19 | 18 | ||
20 | static int cpufreq_governor_powersave(struct cpufreq_policy *policy, | 19 | static int cpufreq_governor_powersave(struct cpufreq_policy *policy, |
21 | unsigned int event) | 20 | unsigned int event) |
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); |
diff --git a/drivers/cpufreq/cris-artpec3-cpufreq.c b/drivers/cpufreq/cris-artpec3-cpufreq.c index ee142c490575..cb8276dd19ca 100644 --- a/drivers/cpufreq/cris-artpec3-cpufreq.c +++ b/drivers/cpufreq/cris-artpec3-cpufreq.c | |||
@@ -111,7 +111,6 @@ static struct cpufreq_driver cris_freq_driver = { | |||
111 | .init = cris_freq_cpu_init, | 111 | .init = cris_freq_cpu_init, |
112 | .exit = cris_freq_cpu_exit, | 112 | .exit = cris_freq_cpu_exit, |
113 | .name = "cris_freq", | 113 | .name = "cris_freq", |
114 | .owner = THIS_MODULE, | ||
115 | .attr = cris_freq_attr, | 114 | .attr = cris_freq_attr, |
116 | }; | 115 | }; |
117 | 116 | ||
diff --git a/drivers/cpufreq/cris-etraxfs-cpufreq.c b/drivers/cpufreq/cris-etraxfs-cpufreq.c index 12952235d5db..72328f77dc53 100644 --- a/drivers/cpufreq/cris-etraxfs-cpufreq.c +++ b/drivers/cpufreq/cris-etraxfs-cpufreq.c | |||
@@ -108,7 +108,6 @@ static struct cpufreq_driver cris_freq_driver = { | |||
108 | .init = cris_freq_cpu_init, | 108 | .init = cris_freq_cpu_init, |
109 | .exit = cris_freq_cpu_exit, | 109 | .exit = cris_freq_cpu_exit, |
110 | .name = "cris_freq", | 110 | .name = "cris_freq", |
111 | .owner = THIS_MODULE, | ||
112 | .attr = cris_freq_attr, | 111 | .attr = cris_freq_attr, |
113 | }; | 112 | }; |
114 | 113 | ||
diff --git a/drivers/cpufreq/e_powersaver.c b/drivers/cpufreq/e_powersaver.c index a60efaeb4cf8..09f64cc83019 100644 --- a/drivers/cpufreq/e_powersaver.c +++ b/drivers/cpufreq/e_powersaver.c | |||
@@ -54,7 +54,7 @@ static struct acpi_processor_performance *eps_acpi_cpu_perf; | |||
54 | /* Minimum necessary to get acpi_processor_get_bios_limit() working */ | 54 | /* Minimum necessary to get acpi_processor_get_bios_limit() working */ |
55 | static int eps_acpi_init(void) | 55 | static int eps_acpi_init(void) |
56 | { | 56 | { |
57 | eps_acpi_cpu_perf = kzalloc(sizeof(struct acpi_processor_performance), | 57 | eps_acpi_cpu_perf = kzalloc(sizeof(*eps_acpi_cpu_perf), |
58 | GFP_KERNEL); | 58 | GFP_KERNEL); |
59 | if (!eps_acpi_cpu_perf) | 59 | if (!eps_acpi_cpu_perf) |
60 | return -ENOMEM; | 60 | return -ENOMEM; |
@@ -366,7 +366,7 @@ static int eps_cpu_init(struct cpufreq_policy *policy) | |||
366 | states = 2; | 366 | states = 2; |
367 | 367 | ||
368 | /* Allocate private data and frequency table for current cpu */ | 368 | /* Allocate private data and frequency table for current cpu */ |
369 | centaur = kzalloc(sizeof(struct eps_cpu_data) | 369 | centaur = kzalloc(sizeof(*centaur) |
370 | + (states + 1) * sizeof(struct cpufreq_frequency_table), | 370 | + (states + 1) * sizeof(struct cpufreq_frequency_table), |
371 | GFP_KERNEL); | 371 | GFP_KERNEL); |
372 | if (!centaur) | 372 | if (!centaur) |
@@ -436,7 +436,6 @@ static struct cpufreq_driver eps_driver = { | |||
436 | .exit = eps_cpu_exit, | 436 | .exit = eps_cpu_exit, |
437 | .get = eps_get, | 437 | .get = eps_get, |
438 | .name = "e_powersaver", | 438 | .name = "e_powersaver", |
439 | .owner = THIS_MODULE, | ||
440 | .attr = eps_attr, | 439 | .attr = eps_attr, |
441 | }; | 440 | }; |
442 | 441 | ||
diff --git a/drivers/cpufreq/elanfreq.c b/drivers/cpufreq/elanfreq.c index 658d860344b0..823a400d98fd 100644 --- a/drivers/cpufreq/elanfreq.c +++ b/drivers/cpufreq/elanfreq.c | |||
@@ -274,7 +274,6 @@ static struct cpufreq_driver elanfreq_driver = { | |||
274 | .init = elanfreq_cpu_init, | 274 | .init = elanfreq_cpu_init, |
275 | .exit = elanfreq_cpu_exit, | 275 | .exit = elanfreq_cpu_exit, |
276 | .name = "elanfreq", | 276 | .name = "elanfreq", |
277 | .owner = THIS_MODULE, | ||
278 | .attr = elanfreq_attr, | 277 | .attr = elanfreq_attr, |
279 | }; | 278 | }; |
280 | 279 | ||
diff --git a/drivers/cpufreq/exynos-cpufreq.c b/drivers/cpufreq/exynos-cpufreq.c index 0d32f02ef4d6..0fac34439e31 100644 --- a/drivers/cpufreq/exynos-cpufreq.c +++ b/drivers/cpufreq/exynos-cpufreq.c | |||
@@ -289,7 +289,7 @@ static int __init exynos_cpufreq_init(void) | |||
289 | { | 289 | { |
290 | int ret = -EINVAL; | 290 | int ret = -EINVAL; |
291 | 291 | ||
292 | exynos_info = kzalloc(sizeof(struct exynos_dvfs_info), GFP_KERNEL); | 292 | exynos_info = kzalloc(sizeof(*exynos_info), GFP_KERNEL); |
293 | if (!exynos_info) | 293 | if (!exynos_info) |
294 | return -ENOMEM; | 294 | return -ENOMEM; |
295 | 295 | ||
@@ -332,7 +332,6 @@ err_cpufreq: | |||
332 | regulator_put(arm_regulator); | 332 | regulator_put(arm_regulator); |
333 | err_vdd_arm: | 333 | err_vdd_arm: |
334 | kfree(exynos_info); | 334 | kfree(exynos_info); |
335 | pr_debug("%s: failed initialization\n", __func__); | ||
336 | return -EINVAL; | 335 | return -EINVAL; |
337 | } | 336 | } |
338 | late_initcall(exynos_cpufreq_init); | 337 | late_initcall(exynos_cpufreq_init); |
diff --git a/drivers/cpufreq/exynos-cpufreq.h b/drivers/cpufreq/exynos-cpufreq.h index 92b852ee5ddc..7f25cee8cec2 100644 --- a/drivers/cpufreq/exynos-cpufreq.h +++ b/drivers/cpufreq/exynos-cpufreq.h | |||
@@ -43,6 +43,27 @@ struct exynos_dvfs_info { | |||
43 | bool (*need_apll_change)(unsigned int, unsigned int); | 43 | bool (*need_apll_change)(unsigned int, unsigned int); |
44 | }; | 44 | }; |
45 | 45 | ||
46 | #ifdef CONFIG_ARM_EXYNOS4210_CPUFREQ | ||
46 | extern int exynos4210_cpufreq_init(struct exynos_dvfs_info *); | 47 | extern int exynos4210_cpufreq_init(struct exynos_dvfs_info *); |
48 | #else | ||
49 | static inline int exynos4210_cpufreq_init(struct exynos_dvfs_info *info) | ||
50 | { | ||
51 | return -EOPNOTSUPP; | ||
52 | } | ||
53 | #endif | ||
54 | #ifdef CONFIG_ARM_EXYNOS4X12_CPUFREQ | ||
47 | extern int exynos4x12_cpufreq_init(struct exynos_dvfs_info *); | 55 | extern int exynos4x12_cpufreq_init(struct exynos_dvfs_info *); |
56 | #else | ||
57 | static inline int exynos4x12_cpufreq_init(struct exynos_dvfs_info *info) | ||
58 | { | ||
59 | return -EOPNOTSUPP; | ||
60 | } | ||
61 | #endif | ||
62 | #ifdef CONFIG_ARM_EXYNOS5250_CPUFREQ | ||
48 | extern int exynos5250_cpufreq_init(struct exynos_dvfs_info *); | 63 | extern int exynos5250_cpufreq_init(struct exynos_dvfs_info *); |
64 | #else | ||
65 | static inline int exynos5250_cpufreq_init(struct exynos_dvfs_info *info) | ||
66 | { | ||
67 | return -EOPNOTSUPP; | ||
68 | } | ||
69 | #endif | ||
diff --git a/drivers/cpufreq/exynos5440-cpufreq.c b/drivers/cpufreq/exynos5440-cpufreq.c index 0c74018eda47..d514c152fd1a 100644 --- a/drivers/cpufreq/exynos5440-cpufreq.c +++ b/drivers/cpufreq/exynos5440-cpufreq.c | |||
@@ -238,6 +238,9 @@ static int exynos_target(struct cpufreq_policy *policy, | |||
238 | freqs.old = dvfs_info->cur_frequency; | 238 | freqs.old = dvfs_info->cur_frequency; |
239 | freqs.new = freq_table[index].frequency; | 239 | freqs.new = freq_table[index].frequency; |
240 | 240 | ||
241 | if (freqs.old == freqs.new) | ||
242 | goto out; | ||
243 | |||
241 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); | 244 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); |
242 | 245 | ||
243 | /* Set the target frequency in all C0_3_PSTATE register */ | 246 | /* Set the target frequency in all C0_3_PSTATE register */ |
diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c index f0d87412cc91..f111454a7aea 100644 --- a/drivers/cpufreq/freq_table.c +++ b/drivers/cpufreq/freq_table.c | |||
@@ -11,10 +11,8 @@ | |||
11 | 11 | ||
12 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | 12 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
13 | 13 | ||
14 | #include <linux/kernel.h> | ||
15 | #include <linux/module.h> | ||
16 | #include <linux/init.h> | ||
17 | #include <linux/cpufreq.h> | 14 | #include <linux/cpufreq.h> |
15 | #include <linux/module.h> | ||
18 | 16 | ||
19 | /********************************************************************* | 17 | /********************************************************************* |
20 | * FREQUENCY TABLE HELPERS * | 18 | * FREQUENCY TABLE HELPERS * |
diff --git a/drivers/cpufreq/gx-suspmod.c b/drivers/cpufreq/gx-suspmod.c index 3dfc99b9ca86..70442c7b5e71 100644 --- a/drivers/cpufreq/gx-suspmod.c +++ b/drivers/cpufreq/gx-suspmod.c | |||
@@ -183,7 +183,7 @@ static void gx_write_byte(int reg, int value) | |||
183 | * gx_detect_chipset: | 183 | * gx_detect_chipset: |
184 | * | 184 | * |
185 | **/ | 185 | **/ |
186 | static __init struct pci_dev *gx_detect_chipset(void) | 186 | static struct pci_dev * __init gx_detect_chipset(void) |
187 | { | 187 | { |
188 | struct pci_dev *gx_pci = NULL; | 188 | struct pci_dev *gx_pci = NULL; |
189 | 189 | ||
@@ -446,7 +446,6 @@ static struct cpufreq_driver gx_suspmod_driver = { | |||
446 | .target = cpufreq_gx_target, | 446 | .target = cpufreq_gx_target, |
447 | .init = cpufreq_gx_cpu_init, | 447 | .init = cpufreq_gx_cpu_init, |
448 | .name = "gx-suspmod", | 448 | .name = "gx-suspmod", |
449 | .owner = THIS_MODULE, | ||
450 | }; | 449 | }; |
451 | 450 | ||
452 | static int __init cpufreq_gx_init(void) | 451 | static int __init cpufreq_gx_init(void) |
@@ -466,7 +465,7 @@ static int __init cpufreq_gx_init(void) | |||
466 | 465 | ||
467 | pr_debug("geode suspend modulation available.\n"); | 466 | pr_debug("geode suspend modulation available.\n"); |
468 | 467 | ||
469 | params = kzalloc(sizeof(struct gxfreq_params), GFP_KERNEL); | 468 | params = kzalloc(sizeof(*params), GFP_KERNEL); |
470 | if (params == NULL) | 469 | if (params == NULL) |
471 | return -ENOMEM; | 470 | return -ENOMEM; |
472 | 471 | ||
diff --git a/drivers/cpufreq/highbank-cpufreq.c b/drivers/cpufreq/highbank-cpufreq.c index b61b5a3fad64..794123fcf3e3 100644 --- a/drivers/cpufreq/highbank-cpufreq.c +++ b/drivers/cpufreq/highbank-cpufreq.c | |||
@@ -69,23 +69,17 @@ static int hb_cpufreq_driver_init(void) | |||
69 | if (!of_machine_is_compatible("calxeda,highbank")) | 69 | if (!of_machine_is_compatible("calxeda,highbank")) |
70 | return -ENODEV; | 70 | return -ENODEV; |
71 | 71 | ||
72 | for_each_child_of_node(of_find_node_by_path("/cpus"), np) | ||
73 | if (of_get_property(np, "operating-points", NULL)) | ||
74 | break; | ||
75 | |||
76 | if (!np) { | ||
77 | pr_err("failed to find highbank cpufreq node\n"); | ||
78 | return -ENOENT; | ||
79 | } | ||
80 | |||
81 | cpu_dev = get_cpu_device(0); | 72 | cpu_dev = get_cpu_device(0); |
82 | if (!cpu_dev) { | 73 | if (!cpu_dev) { |
83 | pr_err("failed to get highbank cpufreq device\n"); | 74 | pr_err("failed to get highbank cpufreq device\n"); |
84 | ret = -ENODEV; | 75 | return -ENODEV; |
85 | goto out_put_node; | ||
86 | } | 76 | } |
87 | 77 | ||
88 | cpu_dev->of_node = np; | 78 | np = of_node_get(cpu_dev->of_node); |
79 | if (!np) { | ||
80 | pr_err("failed to find highbank cpufreq node\n"); | ||
81 | return -ENOENT; | ||
82 | } | ||
89 | 83 | ||
90 | cpu_clk = clk_get(cpu_dev, NULL); | 84 | cpu_clk = clk_get(cpu_dev, NULL); |
91 | if (IS_ERR(cpu_clk)) { | 85 | if (IS_ERR(cpu_clk)) { |
diff --git a/drivers/cpufreq/ia64-acpi-cpufreq.c b/drivers/cpufreq/ia64-acpi-cpufreq.c index 573c14ea802d..3e14f0317175 100644 --- a/drivers/cpufreq/ia64-acpi-cpufreq.c +++ b/drivers/cpufreq/ia64-acpi-cpufreq.c | |||
@@ -274,7 +274,7 @@ acpi_cpufreq_cpu_init ( | |||
274 | 274 | ||
275 | pr_debug("acpi_cpufreq_cpu_init\n"); | 275 | pr_debug("acpi_cpufreq_cpu_init\n"); |
276 | 276 | ||
277 | data = kzalloc(sizeof(struct cpufreq_acpi_io), GFP_KERNEL); | 277 | data = kzalloc(sizeof(*data), GFP_KERNEL); |
278 | if (!data) | 278 | if (!data) |
279 | return (-ENOMEM); | 279 | return (-ENOMEM); |
280 | 280 | ||
@@ -304,7 +304,7 @@ acpi_cpufreq_cpu_init ( | |||
304 | } | 304 | } |
305 | 305 | ||
306 | /* alloc freq_table */ | 306 | /* alloc freq_table */ |
307 | data->freq_table = kmalloc(sizeof(struct cpufreq_frequency_table) * | 307 | data->freq_table = kmalloc(sizeof(*data->freq_table) * |
308 | (data->acpi_data.state_count + 1), | 308 | (data->acpi_data.state_count + 1), |
309 | GFP_KERNEL); | 309 | GFP_KERNEL); |
310 | if (!data->freq_table) { | 310 | if (!data->freq_table) { |
@@ -409,7 +409,6 @@ static struct cpufreq_driver acpi_cpufreq_driver = { | |||
409 | .init = acpi_cpufreq_cpu_init, | 409 | .init = acpi_cpufreq_cpu_init, |
410 | .exit = acpi_cpufreq_cpu_exit, | 410 | .exit = acpi_cpufreq_cpu_exit, |
411 | .name = "acpi-cpufreq", | 411 | .name = "acpi-cpufreq", |
412 | .owner = THIS_MODULE, | ||
413 | .attr = acpi_cpufreq_attr, | 412 | .attr = acpi_cpufreq_attr, |
414 | }; | 413 | }; |
415 | 414 | ||
diff --git a/drivers/cpufreq/imx6q-cpufreq.c b/drivers/cpufreq/imx6q-cpufreq.c index 2971d12b28e8..3e396543aea4 100644 --- a/drivers/cpufreq/imx6q-cpufreq.c +++ b/drivers/cpufreq/imx6q-cpufreq.c | |||
@@ -204,14 +204,12 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev) | |||
204 | 204 | ||
205 | cpu_dev = &pdev->dev; | 205 | cpu_dev = &pdev->dev; |
206 | 206 | ||
207 | np = of_find_node_by_path("/cpus/cpu@0"); | 207 | np = of_node_get(cpu_dev->of_node); |
208 | if (!np) { | 208 | if (!np) { |
209 | dev_err(cpu_dev, "failed to find cpu0 node\n"); | 209 | dev_err(cpu_dev, "failed to find cpu0 node\n"); |
210 | return -ENOENT; | 210 | return -ENOENT; |
211 | } | 211 | } |
212 | 212 | ||
213 | cpu_dev->of_node = np; | ||
214 | |||
215 | arm_clk = devm_clk_get(cpu_dev, "arm"); | 213 | arm_clk = devm_clk_get(cpu_dev, "arm"); |
216 | pll1_sys_clk = devm_clk_get(cpu_dev, "pll1_sys"); | 214 | pll1_sys_clk = devm_clk_get(cpu_dev, "pll1_sys"); |
217 | pll1_sw_clk = devm_clk_get(cpu_dev, "pll1_sw"); | 215 | pll1_sw_clk = devm_clk_get(cpu_dev, "pll1_sw"); |
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index 7cde885011ed..6efd96c196b2 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c | |||
@@ -665,7 +665,6 @@ static struct cpufreq_driver intel_pstate_driver = { | |||
665 | .init = intel_pstate_cpu_init, | 665 | .init = intel_pstate_cpu_init, |
666 | .exit = intel_pstate_cpu_exit, | 666 | .exit = intel_pstate_cpu_exit, |
667 | .name = "intel_pstate", | 667 | .name = "intel_pstate", |
668 | .owner = THIS_MODULE, | ||
669 | }; | 668 | }; |
670 | 669 | ||
671 | static int __initdata no_load; | 670 | static int __initdata no_load; |
diff --git a/drivers/cpufreq/kirkwood-cpufreq.c b/drivers/cpufreq/kirkwood-cpufreq.c index c233ea617366..ba10658a9394 100644 --- a/drivers/cpufreq/kirkwood-cpufreq.c +++ b/drivers/cpufreq/kirkwood-cpufreq.c | |||
@@ -14,7 +14,7 @@ | |||
14 | #include <linux/clk.h> | 14 | #include <linux/clk.h> |
15 | #include <linux/clk-provider.h> | 15 | #include <linux/clk-provider.h> |
16 | #include <linux/cpufreq.h> | 16 | #include <linux/cpufreq.h> |
17 | #include <linux/of.h> | 17 | #include <linux/of_device.h> |
18 | #include <linux/platform_device.h> | 18 | #include <linux/platform_device.h> |
19 | #include <linux/io.h> | 19 | #include <linux/io.h> |
20 | #include <asm/proc-fns.h> | 20 | #include <asm/proc-fns.h> |
@@ -158,7 +158,6 @@ static struct cpufreq_driver kirkwood_cpufreq_driver = { | |||
158 | .init = kirkwood_cpufreq_cpu_init, | 158 | .init = kirkwood_cpufreq_cpu_init, |
159 | .exit = kirkwood_cpufreq_cpu_exit, | 159 | .exit = kirkwood_cpufreq_cpu_exit, |
160 | .name = "kirkwood-cpufreq", | 160 | .name = "kirkwood-cpufreq", |
161 | .owner = THIS_MODULE, | ||
162 | .attr = kirkwood_cpufreq_attr, | 161 | .attr = kirkwood_cpufreq_attr, |
163 | }; | 162 | }; |
164 | 163 | ||
@@ -175,9 +174,11 @@ static int kirkwood_cpufreq_probe(struct platform_device *pdev) | |||
175 | if (IS_ERR(priv.base)) | 174 | if (IS_ERR(priv.base)) |
176 | return PTR_ERR(priv.base); | 175 | return PTR_ERR(priv.base); |
177 | 176 | ||
178 | np = of_find_node_by_path("/cpus/cpu@0"); | 177 | np = of_cpu_device_node_get(0); |
179 | if (!np) | 178 | if (!np) { |
179 | dev_err(&pdev->dev, "failed to get cpu device node\n"); | ||
180 | return -ENODEV; | 180 | return -ENODEV; |
181 | } | ||
181 | 182 | ||
182 | priv.cpu_clk = of_clk_get_by_name(np, "cpu_clk"); | 183 | priv.cpu_clk = of_clk_get_by_name(np, "cpu_clk"); |
183 | if (IS_ERR(priv.cpu_clk)) { | 184 | if (IS_ERR(priv.cpu_clk)) { |
diff --git a/drivers/cpufreq/longhaul.c b/drivers/cpufreq/longhaul.c index 8c49261df57d..4ada1cccb052 100644 --- a/drivers/cpufreq/longhaul.c +++ b/drivers/cpufreq/longhaul.c | |||
@@ -948,7 +948,6 @@ static struct cpufreq_driver longhaul_driver = { | |||
948 | .init = longhaul_cpu_init, | 948 | .init = longhaul_cpu_init, |
949 | .exit = longhaul_cpu_exit, | 949 | .exit = longhaul_cpu_exit, |
950 | .name = "longhaul", | 950 | .name = "longhaul", |
951 | .owner = THIS_MODULE, | ||
952 | .attr = longhaul_attr, | 951 | .attr = longhaul_attr, |
953 | }; | 952 | }; |
954 | 953 | ||
diff --git a/drivers/cpufreq/longrun.c b/drivers/cpufreq/longrun.c index 0fe041d1f77f..5aa031612d53 100644 --- a/drivers/cpufreq/longrun.c +++ b/drivers/cpufreq/longrun.c | |||
@@ -286,7 +286,6 @@ static struct cpufreq_driver longrun_driver = { | |||
286 | .get = longrun_get, | 286 | .get = longrun_get, |
287 | .init = longrun_cpu_init, | 287 | .init = longrun_cpu_init, |
288 | .name = "longrun", | 288 | .name = "longrun", |
289 | .owner = THIS_MODULE, | ||
290 | }; | 289 | }; |
291 | 290 | ||
292 | static const struct x86_cpu_id longrun_ids[] = { | 291 | static const struct x86_cpu_id longrun_ids[] = { |
diff --git a/drivers/cpufreq/loongson2_cpufreq.c b/drivers/cpufreq/loongson2_cpufreq.c index 9536852c504a..7bc3c44d34e2 100644 --- a/drivers/cpufreq/loongson2_cpufreq.c +++ b/drivers/cpufreq/loongson2_cpufreq.c | |||
@@ -158,7 +158,6 @@ static struct freq_attr *loongson2_table_attr[] = { | |||
158 | }; | 158 | }; |
159 | 159 | ||
160 | static struct cpufreq_driver loongson2_cpufreq_driver = { | 160 | static struct cpufreq_driver loongson2_cpufreq_driver = { |
161 | .owner = THIS_MODULE, | ||
162 | .name = "loongson2", | 161 | .name = "loongson2", |
163 | .init = loongson2_cpufreq_cpu_init, | 162 | .init = loongson2_cpufreq_cpu_init, |
164 | .verify = loongson2_cpufreq_verify, | 163 | .verify = loongson2_cpufreq_verify, |
diff --git a/drivers/cpufreq/maple-cpufreq.c b/drivers/cpufreq/maple-cpufreq.c index cdd62915efaf..6168d77b296d 100644 --- a/drivers/cpufreq/maple-cpufreq.c +++ b/drivers/cpufreq/maple-cpufreq.c | |||
@@ -24,7 +24,7 @@ | |||
24 | #include <linux/completion.h> | 24 | #include <linux/completion.h> |
25 | #include <linux/mutex.h> | 25 | #include <linux/mutex.h> |
26 | #include <linux/time.h> | 26 | #include <linux/time.h> |
27 | #include <linux/of.h> | 27 | #include <linux/of_device.h> |
28 | 28 | ||
29 | #define DBG(fmt...) pr_debug(fmt) | 29 | #define DBG(fmt...) pr_debug(fmt) |
30 | 30 | ||
@@ -190,7 +190,6 @@ static int maple_cpufreq_cpu_init(struct cpufreq_policy *policy) | |||
190 | 190 | ||
191 | static struct cpufreq_driver maple_cpufreq_driver = { | 191 | static struct cpufreq_driver maple_cpufreq_driver = { |
192 | .name = "maple", | 192 | .name = "maple", |
193 | .owner = THIS_MODULE, | ||
194 | .flags = CPUFREQ_CONST_LOOPS, | 193 | .flags = CPUFREQ_CONST_LOOPS, |
195 | .init = maple_cpufreq_cpu_init, | 194 | .init = maple_cpufreq_cpu_init, |
196 | .verify = maple_cpufreq_verify, | 195 | .verify = maple_cpufreq_verify, |
@@ -201,7 +200,6 @@ static struct cpufreq_driver maple_cpufreq_driver = { | |||
201 | 200 | ||
202 | static int __init maple_cpufreq_init(void) | 201 | static int __init maple_cpufreq_init(void) |
203 | { | 202 | { |
204 | struct device_node *cpus; | ||
205 | struct device_node *cpunode; | 203 | struct device_node *cpunode; |
206 | unsigned int psize; | 204 | unsigned int psize; |
207 | unsigned long max_freq; | 205 | unsigned long max_freq; |
@@ -217,24 +215,11 @@ static int __init maple_cpufreq_init(void) | |||
217 | !of_machine_is_compatible("Momentum,Apache")) | 215 | !of_machine_is_compatible("Momentum,Apache")) |
218 | return 0; | 216 | return 0; |
219 | 217 | ||
220 | cpus = of_find_node_by_path("/cpus"); | ||
221 | if (cpus == NULL) { | ||
222 | DBG("No /cpus node !\n"); | ||
223 | return -ENODEV; | ||
224 | } | ||
225 | |||
226 | /* Get first CPU node */ | 218 | /* Get first CPU node */ |
227 | for (cpunode = NULL; | 219 | cpunode = of_cpu_device_node_get(0); |
228 | (cpunode = of_get_next_child(cpus, cpunode)) != NULL;) { | ||
229 | const u32 *reg = of_get_property(cpunode, "reg", NULL); | ||
230 | if (reg == NULL || (*reg) != 0) | ||
231 | continue; | ||
232 | if (!strcmp(cpunode->type, "cpu")) | ||
233 | break; | ||
234 | } | ||
235 | if (cpunode == NULL) { | 220 | if (cpunode == NULL) { |
236 | printk(KERN_ERR "cpufreq: Can't find any CPU 0 node\n"); | 221 | printk(KERN_ERR "cpufreq: Can't find any CPU 0 node\n"); |
237 | goto bail_cpus; | 222 | goto bail_noprops; |
238 | } | 223 | } |
239 | 224 | ||
240 | /* Check 970FX for now */ | 225 | /* Check 970FX for now */ |
@@ -290,14 +275,11 @@ static int __init maple_cpufreq_init(void) | |||
290 | rc = cpufreq_register_driver(&maple_cpufreq_driver); | 275 | rc = cpufreq_register_driver(&maple_cpufreq_driver); |
291 | 276 | ||
292 | of_node_put(cpunode); | 277 | of_node_put(cpunode); |
293 | of_node_put(cpus); | ||
294 | 278 | ||
295 | return rc; | 279 | return rc; |
296 | 280 | ||
297 | bail_noprops: | 281 | bail_noprops: |
298 | of_node_put(cpunode); | 282 | of_node_put(cpunode); |
299 | bail_cpus: | ||
300 | of_node_put(cpus); | ||
301 | 283 | ||
302 | return rc; | 284 | return rc; |
303 | } | 285 | } |
diff --git a/drivers/cpufreq/mperf.c b/drivers/cpufreq/mperf.c deleted file mode 100644 index 911e193018ae..000000000000 --- a/drivers/cpufreq/mperf.c +++ /dev/null | |||
@@ -1,51 +0,0 @@ | |||
1 | #include <linux/kernel.h> | ||
2 | #include <linux/smp.h> | ||
3 | #include <linux/module.h> | ||
4 | #include <linux/init.h> | ||
5 | #include <linux/cpufreq.h> | ||
6 | #include <linux/slab.h> | ||
7 | |||
8 | #include "mperf.h" | ||
9 | |||
10 | static DEFINE_PER_CPU(struct aperfmperf, acfreq_old_perf); | ||
11 | |||
12 | /* Called via smp_call_function_single(), on the target CPU */ | ||
13 | static void read_measured_perf_ctrs(void *_cur) | ||
14 | { | ||
15 | struct aperfmperf *am = _cur; | ||
16 | |||
17 | get_aperfmperf(am); | ||
18 | } | ||
19 | |||
20 | /* | ||
21 | * Return the measured active (C0) frequency on this CPU since last call | ||
22 | * to this function. | ||
23 | * Input: cpu number | ||
24 | * Return: Average CPU frequency in terms of max frequency (zero on error) | ||
25 | * | ||
26 | * We use IA32_MPERF and IA32_APERF MSRs to get the measured performance | ||
27 | * over a period of time, while CPU is in C0 state. | ||
28 | * IA32_MPERF counts at the rate of max advertised frequency | ||
29 | * IA32_APERF counts at the rate of actual CPU frequency | ||
30 | * Only IA32_APERF/IA32_MPERF ratio is architecturally defined and | ||
31 | * no meaning should be associated with absolute values of these MSRs. | ||
32 | */ | ||
33 | unsigned int cpufreq_get_measured_perf(struct cpufreq_policy *policy, | ||
34 | unsigned int cpu) | ||
35 | { | ||
36 | struct aperfmperf perf; | ||
37 | unsigned long ratio; | ||
38 | unsigned int retval; | ||
39 | |||
40 | if (smp_call_function_single(cpu, read_measured_perf_ctrs, &perf, 1)) | ||
41 | return 0; | ||
42 | |||
43 | ratio = calc_aperfmperf_ratio(&per_cpu(acfreq_old_perf, cpu), &perf); | ||
44 | per_cpu(acfreq_old_perf, cpu) = perf; | ||
45 | |||
46 | retval = (policy->cpuinfo.max_freq * ratio) >> APERFMPERF_SHIFT; | ||
47 | |||
48 | return retval; | ||
49 | } | ||
50 | EXPORT_SYMBOL_GPL(cpufreq_get_measured_perf); | ||
51 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/cpufreq/mperf.h b/drivers/cpufreq/mperf.h deleted file mode 100644 index 5dbf2950dc22..000000000000 --- a/drivers/cpufreq/mperf.h +++ /dev/null | |||
@@ -1,9 +0,0 @@ | |||
1 | /* | ||
2 | * (c) 2010 Advanced Micro Devices, Inc. | ||
3 | * Your use of this code is subject to the terms and conditions of the | ||
4 | * GNU general public license version 2. See "COPYING" or | ||
5 | * http://www.gnu.org/licenses/gpl.html | ||
6 | */ | ||
7 | |||
8 | unsigned int cpufreq_get_measured_perf(struct cpufreq_policy *policy, | ||
9 | unsigned int cpu); | ||
diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c index 9ee78170ff86..2f0a2a65c37f 100644 --- a/drivers/cpufreq/p4-clockmod.c +++ b/drivers/cpufreq/p4-clockmod.c | |||
@@ -279,7 +279,6 @@ static struct cpufreq_driver p4clockmod_driver = { | |||
279 | .exit = cpufreq_p4_cpu_exit, | 279 | .exit = cpufreq_p4_cpu_exit, |
280 | .get = cpufreq_p4_get, | 280 | .get = cpufreq_p4_get, |
281 | .name = "p4-clockmod", | 281 | .name = "p4-clockmod", |
282 | .owner = THIS_MODULE, | ||
283 | .attr = p4clockmod_attr, | 282 | .attr = p4clockmod_attr, |
284 | }; | 283 | }; |
285 | 284 | ||
diff --git a/drivers/cpufreq/pasemi-cpufreq.c b/drivers/cpufreq/pasemi-cpufreq.c index b704da404067..534e43a60d1f 100644 --- a/drivers/cpufreq/pasemi-cpufreq.c +++ b/drivers/cpufreq/pasemi-cpufreq.c | |||
@@ -297,7 +297,6 @@ static int pas_cpufreq_target(struct cpufreq_policy *policy, | |||
297 | 297 | ||
298 | static struct cpufreq_driver pas_cpufreq_driver = { | 298 | static struct cpufreq_driver pas_cpufreq_driver = { |
299 | .name = "pas-cpufreq", | 299 | .name = "pas-cpufreq", |
300 | .owner = THIS_MODULE, | ||
301 | .flags = CPUFREQ_CONST_LOOPS, | 300 | .flags = CPUFREQ_CONST_LOOPS, |
302 | .init = pas_cpufreq_cpu_init, | 301 | .init = pas_cpufreq_cpu_init, |
303 | .exit = pas_cpufreq_cpu_exit, | 302 | .exit = pas_cpufreq_cpu_exit, |
diff --git a/drivers/cpufreq/pcc-cpufreq.c b/drivers/cpufreq/pcc-cpufreq.c index 1581fcc4cf4a..d81c4e5ea0ad 100644 --- a/drivers/cpufreq/pcc-cpufreq.c +++ b/drivers/cpufreq/pcc-cpufreq.c | |||
@@ -587,7 +587,6 @@ static struct cpufreq_driver pcc_cpufreq_driver = { | |||
587 | .init = pcc_cpufreq_cpu_init, | 587 | .init = pcc_cpufreq_cpu_init, |
588 | .exit = pcc_cpufreq_cpu_exit, | 588 | .exit = pcc_cpufreq_cpu_exit, |
589 | .name = "pcc-cpufreq", | 589 | .name = "pcc-cpufreq", |
590 | .owner = THIS_MODULE, | ||
591 | }; | 590 | }; |
592 | 591 | ||
593 | static int __init pcc_cpufreq_init(void) | 592 | static int __init pcc_cpufreq_init(void) |
diff --git a/drivers/cpufreq/pmac32-cpufreq.c b/drivers/cpufreq/pmac32-cpufreq.c index 3104fad82480..a096cd3fa23d 100644 --- a/drivers/cpufreq/pmac32-cpufreq.c +++ b/drivers/cpufreq/pmac32-cpufreq.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <linux/init.h> | 25 | #include <linux/init.h> |
26 | #include <linux/device.h> | 26 | #include <linux/device.h> |
27 | #include <linux/hardirq.h> | 27 | #include <linux/hardirq.h> |
28 | #include <linux/of_device.h> | ||
28 | #include <asm/prom.h> | 29 | #include <asm/prom.h> |
29 | #include <asm/machdep.h> | 30 | #include <asm/machdep.h> |
30 | #include <asm/irq.h> | 31 | #include <asm/irq.h> |
@@ -477,7 +478,6 @@ static struct cpufreq_driver pmac_cpufreq_driver = { | |||
477 | .flags = CPUFREQ_PM_NO_WARN, | 478 | .flags = CPUFREQ_PM_NO_WARN, |
478 | .attr = pmac_cpu_freqs_attr, | 479 | .attr = pmac_cpu_freqs_attr, |
479 | .name = "powermac", | 480 | .name = "powermac", |
480 | .owner = THIS_MODULE, | ||
481 | }; | 481 | }; |
482 | 482 | ||
483 | 483 | ||
@@ -649,8 +649,8 @@ static int __init pmac_cpufreq_setup(void) | |||
649 | if (strstr(cmd_line, "nocpufreq")) | 649 | if (strstr(cmd_line, "nocpufreq")) |
650 | return 0; | 650 | return 0; |
651 | 651 | ||
652 | /* Assume only one CPU */ | 652 | /* Get first CPU node */ |
653 | cpunode = of_find_node_by_type(NULL, "cpu"); | 653 | cpunode = of_cpu_device_node_get(0); |
654 | if (!cpunode) | 654 | if (!cpunode) |
655 | goto out; | 655 | goto out; |
656 | 656 | ||
diff --git a/drivers/cpufreq/pmac64-cpufreq.c b/drivers/cpufreq/pmac64-cpufreq.c index 7ba423431cfe..3a51ad7e47c8 100644 --- a/drivers/cpufreq/pmac64-cpufreq.c +++ b/drivers/cpufreq/pmac64-cpufreq.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/init.h> | 22 | #include <linux/init.h> |
23 | #include <linux/completion.h> | 23 | #include <linux/completion.h> |
24 | #include <linux/mutex.h> | 24 | #include <linux/mutex.h> |
25 | #include <linux/of_device.h> | ||
25 | #include <asm/prom.h> | 26 | #include <asm/prom.h> |
26 | #include <asm/machdep.h> | 27 | #include <asm/machdep.h> |
27 | #include <asm/irq.h> | 28 | #include <asm/irq.h> |
@@ -371,7 +372,6 @@ static int g5_cpufreq_cpu_init(struct cpufreq_policy *policy) | |||
371 | 372 | ||
372 | static struct cpufreq_driver g5_cpufreq_driver = { | 373 | static struct cpufreq_driver g5_cpufreq_driver = { |
373 | .name = "powermac", | 374 | .name = "powermac", |
374 | .owner = THIS_MODULE, | ||
375 | .flags = CPUFREQ_CONST_LOOPS, | 375 | .flags = CPUFREQ_CONST_LOOPS, |
376 | .init = g5_cpufreq_cpu_init, | 376 | .init = g5_cpufreq_cpu_init, |
377 | .verify = g5_cpufreq_verify, | 377 | .verify = g5_cpufreq_verify, |
@@ -383,9 +383,8 @@ static struct cpufreq_driver g5_cpufreq_driver = { | |||
383 | 383 | ||
384 | #ifdef CONFIG_PMAC_SMU | 384 | #ifdef CONFIG_PMAC_SMU |
385 | 385 | ||
386 | static int __init g5_neo2_cpufreq_init(struct device_node *cpus) | 386 | static int __init g5_neo2_cpufreq_init(struct device_node *cpunode) |
387 | { | 387 | { |
388 | struct device_node *cpunode; | ||
389 | unsigned int psize, ssize; | 388 | unsigned int psize, ssize; |
390 | unsigned long max_freq; | 389 | unsigned long max_freq; |
391 | char *freq_method, *volt_method; | 390 | char *freq_method, *volt_method; |
@@ -405,20 +404,6 @@ static int __init g5_neo2_cpufreq_init(struct device_node *cpus) | |||
405 | else | 404 | else |
406 | return -ENODEV; | 405 | return -ENODEV; |
407 | 406 | ||
408 | /* Get first CPU node */ | ||
409 | for (cpunode = NULL; | ||
410 | (cpunode = of_get_next_child(cpus, cpunode)) != NULL;) { | ||
411 | const u32 *reg = of_get_property(cpunode, "reg", NULL); | ||
412 | if (reg == NULL || (*reg) != 0) | ||
413 | continue; | ||
414 | if (!strcmp(cpunode->type, "cpu")) | ||
415 | break; | ||
416 | } | ||
417 | if (cpunode == NULL) { | ||
418 | printk(KERN_ERR "cpufreq: Can't find any CPU 0 node\n"); | ||
419 | return -ENODEV; | ||
420 | } | ||
421 | |||
422 | /* Check 970FX for now */ | 407 | /* Check 970FX for now */ |
423 | valp = of_get_property(cpunode, "cpu-version", NULL); | 408 | valp = of_get_property(cpunode, "cpu-version", NULL); |
424 | if (!valp) { | 409 | if (!valp) { |
@@ -447,9 +432,8 @@ static int __init g5_neo2_cpufreq_init(struct device_node *cpus) | |||
447 | if (!shdr) | 432 | if (!shdr) |
448 | goto bail_noprops; | 433 | goto bail_noprops; |
449 | g5_fvt_table = (struct smu_sdbp_fvt *)&shdr[1]; | 434 | g5_fvt_table = (struct smu_sdbp_fvt *)&shdr[1]; |
450 | ssize = (shdr->len * sizeof(u32)) - | 435 | ssize = (shdr->len * sizeof(u32)) - sizeof(*shdr); |
451 | sizeof(struct smu_sdbp_header); | 436 | g5_fvt_count = ssize / sizeof(*g5_fvt_table); |
452 | g5_fvt_count = ssize / sizeof(struct smu_sdbp_fvt); | ||
453 | g5_fvt_cur = 0; | 437 | g5_fvt_cur = 0; |
454 | 438 | ||
455 | /* Sanity checking */ | 439 | /* Sanity checking */ |
@@ -537,9 +521,9 @@ static int __init g5_neo2_cpufreq_init(struct device_node *cpus) | |||
537 | #endif /* CONFIG_PMAC_SMU */ | 521 | #endif /* CONFIG_PMAC_SMU */ |
538 | 522 | ||
539 | 523 | ||
540 | static int __init g5_pm72_cpufreq_init(struct device_node *cpus) | 524 | static int __init g5_pm72_cpufreq_init(struct device_node *cpunode) |
541 | { | 525 | { |
542 | struct device_node *cpuid = NULL, *hwclock = NULL, *cpunode = NULL; | 526 | struct device_node *cpuid = NULL, *hwclock = NULL; |
543 | const u8 *eeprom = NULL; | 527 | const u8 *eeprom = NULL; |
544 | const u32 *valp; | 528 | const u32 *valp; |
545 | u64 max_freq, min_freq, ih, il; | 529 | u64 max_freq, min_freq, ih, il; |
@@ -548,17 +532,6 @@ static int __init g5_pm72_cpufreq_init(struct device_node *cpus) | |||
548 | DBG("cpufreq: Initializing for PowerMac7,2, PowerMac7,3 and" | 532 | DBG("cpufreq: Initializing for PowerMac7,2, PowerMac7,3 and" |
549 | " RackMac3,1...\n"); | 533 | " RackMac3,1...\n"); |
550 | 534 | ||
551 | /* Get first CPU node */ | ||
552 | for (cpunode = NULL; | ||
553 | (cpunode = of_get_next_child(cpus, cpunode)) != NULL;) { | ||
554 | if (!strcmp(cpunode->type, "cpu")) | ||
555 | break; | ||
556 | } | ||
557 | if (cpunode == NULL) { | ||
558 | printk(KERN_ERR "cpufreq: Can't find any CPU node\n"); | ||
559 | return -ENODEV; | ||
560 | } | ||
561 | |||
562 | /* Lookup the cpuid eeprom node */ | 535 | /* Lookup the cpuid eeprom node */ |
563 | cpuid = of_find_node_by_path("/u3@0,f8000000/i2c@f8001000/cpuid@a0"); | 536 | cpuid = of_find_node_by_path("/u3@0,f8000000/i2c@f8001000/cpuid@a0"); |
564 | if (cpuid != NULL) | 537 | if (cpuid != NULL) |
@@ -718,25 +691,25 @@ static int __init g5_pm72_cpufreq_init(struct device_node *cpus) | |||
718 | 691 | ||
719 | static int __init g5_cpufreq_init(void) | 692 | static int __init g5_cpufreq_init(void) |
720 | { | 693 | { |
721 | struct device_node *cpus; | 694 | struct device_node *cpunode; |
722 | int rc = 0; | 695 | int rc = 0; |
723 | 696 | ||
724 | cpus = of_find_node_by_path("/cpus"); | 697 | /* Get first CPU node */ |
725 | if (cpus == NULL) { | 698 | cpunode = of_cpu_device_node_get(0); |
726 | DBG("No /cpus node !\n"); | 699 | if (cpunode == NULL) { |
700 | pr_err("cpufreq: Can't find any CPU node\n"); | ||
727 | return -ENODEV; | 701 | return -ENODEV; |
728 | } | 702 | } |
729 | 703 | ||
730 | if (of_machine_is_compatible("PowerMac7,2") || | 704 | if (of_machine_is_compatible("PowerMac7,2") || |
731 | of_machine_is_compatible("PowerMac7,3") || | 705 | of_machine_is_compatible("PowerMac7,3") || |
732 | of_machine_is_compatible("RackMac3,1")) | 706 | of_machine_is_compatible("RackMac3,1")) |
733 | rc = g5_pm72_cpufreq_init(cpus); | 707 | rc = g5_pm72_cpufreq_init(cpunode); |
734 | #ifdef CONFIG_PMAC_SMU | 708 | #ifdef CONFIG_PMAC_SMU |
735 | else | 709 | else |
736 | rc = g5_neo2_cpufreq_init(cpus); | 710 | rc = g5_neo2_cpufreq_init(cpunode); |
737 | #endif /* CONFIG_PMAC_SMU */ | 711 | #endif /* CONFIG_PMAC_SMU */ |
738 | 712 | ||
739 | of_node_put(cpus); | ||
740 | return rc; | 713 | return rc; |
741 | } | 714 | } |
742 | 715 | ||
diff --git a/drivers/cpufreq/powernow-k6.c b/drivers/cpufreq/powernow-k6.c index ea8e10382ec5..85f1c8c25ddc 100644 --- a/drivers/cpufreq/powernow-k6.c +++ b/drivers/cpufreq/powernow-k6.c | |||
@@ -207,7 +207,6 @@ static struct cpufreq_driver powernow_k6_driver = { | |||
207 | .exit = powernow_k6_cpu_exit, | 207 | .exit = powernow_k6_cpu_exit, |
208 | .get = powernow_k6_get, | 208 | .get = powernow_k6_get, |
209 | .name = "powernow-k6", | 209 | .name = "powernow-k6", |
210 | .owner = THIS_MODULE, | ||
211 | .attr = powernow_k6_attr, | 210 | .attr = powernow_k6_attr, |
212 | }; | 211 | }; |
213 | 212 | ||
diff --git a/drivers/cpufreq/powernow-k7.c b/drivers/cpufreq/powernow-k7.c index 955870877935..14ce480be8ab 100644 --- a/drivers/cpufreq/powernow-k7.c +++ b/drivers/cpufreq/powernow-k7.c | |||
@@ -177,7 +177,7 @@ static int get_ranges(unsigned char *pst) | |||
177 | unsigned int speed; | 177 | unsigned int speed; |
178 | u8 fid, vid; | 178 | u8 fid, vid; |
179 | 179 | ||
180 | powernow_table = kzalloc((sizeof(struct cpufreq_frequency_table) * | 180 | powernow_table = kzalloc((sizeof(*powernow_table) * |
181 | (number_scales + 1)), GFP_KERNEL); | 181 | (number_scales + 1)), GFP_KERNEL); |
182 | if (!powernow_table) | 182 | if (!powernow_table) |
183 | return -ENOMEM; | 183 | return -ENOMEM; |
@@ -309,8 +309,7 @@ static int powernow_acpi_init(void) | |||
309 | goto err0; | 309 | goto err0; |
310 | } | 310 | } |
311 | 311 | ||
312 | acpi_processor_perf = kzalloc(sizeof(struct acpi_processor_performance), | 312 | acpi_processor_perf = kzalloc(sizeof(*acpi_processor_perf), GFP_KERNEL); |
313 | GFP_KERNEL); | ||
314 | if (!acpi_processor_perf) { | 313 | if (!acpi_processor_perf) { |
315 | retval = -ENOMEM; | 314 | retval = -ENOMEM; |
316 | goto err0; | 315 | goto err0; |
@@ -346,7 +345,7 @@ static int powernow_acpi_init(void) | |||
346 | goto err2; | 345 | goto err2; |
347 | } | 346 | } |
348 | 347 | ||
349 | powernow_table = kzalloc((sizeof(struct cpufreq_frequency_table) * | 348 | powernow_table = kzalloc((sizeof(*powernow_table) * |
350 | (number_scales + 1)), GFP_KERNEL); | 349 | (number_scales + 1)), GFP_KERNEL); |
351 | if (!powernow_table) { | 350 | if (!powernow_table) { |
352 | retval = -ENOMEM; | 351 | retval = -ENOMEM; |
@@ -497,7 +496,7 @@ static int powernow_decode_bios(int maxfid, int startvid) | |||
497 | "relevant to this CPU).\n", | 496 | "relevant to this CPU).\n", |
498 | psb->numpst); | 497 | psb->numpst); |
499 | 498 | ||
500 | p += sizeof(struct psb_s); | 499 | p += sizeof(*psb); |
501 | 500 | ||
502 | pst = (struct pst_s *) p; | 501 | pst = (struct pst_s *) p; |
503 | 502 | ||
@@ -510,12 +509,12 @@ static int powernow_decode_bios(int maxfid, int startvid) | |||
510 | (maxfid == pst->maxfid) && | 509 | (maxfid == pst->maxfid) && |
511 | (startvid == pst->startvid)) { | 510 | (startvid == pst->startvid)) { |
512 | print_pst_entry(pst, j); | 511 | print_pst_entry(pst, j); |
513 | p = (char *)pst + sizeof(struct pst_s); | 512 | p = (char *)pst + sizeof(*pst); |
514 | ret = get_ranges(p); | 513 | ret = get_ranges(p); |
515 | return ret; | 514 | return ret; |
516 | } else { | 515 | } else { |
517 | unsigned int k; | 516 | unsigned int k; |
518 | p = (char *)pst + sizeof(struct pst_s); | 517 | p = (char *)pst + sizeof(*pst); |
519 | for (k = 0; k < number_scales; k++) | 518 | for (k = 0; k < number_scales; k++) |
520 | p += 2; | 519 | p += 2; |
521 | } | 520 | } |
@@ -717,7 +716,6 @@ static struct cpufreq_driver powernow_driver = { | |||
717 | .init = powernow_cpu_init, | 716 | .init = powernow_cpu_init, |
718 | .exit = powernow_cpu_exit, | 717 | .exit = powernow_cpu_exit, |
719 | .name = "powernow-k7", | 718 | .name = "powernow-k7", |
720 | .owner = THIS_MODULE, | ||
721 | .attr = powernow_table_attr, | 719 | .attr = powernow_table_attr, |
722 | }; | 720 | }; |
723 | 721 | ||
diff --git a/drivers/cpufreq/powernow-k8.c b/drivers/cpufreq/powernow-k8.c index c39d189217cb..2344a9ed17f3 100644 --- a/drivers/cpufreq/powernow-k8.c +++ b/drivers/cpufreq/powernow-k8.c | |||
@@ -623,7 +623,7 @@ static int fill_powernow_table(struct powernow_k8_data *data, | |||
623 | if (check_pst_table(data, pst, maxvid)) | 623 | if (check_pst_table(data, pst, maxvid)) |
624 | return -EINVAL; | 624 | return -EINVAL; |
625 | 625 | ||
626 | powernow_table = kmalloc((sizeof(struct cpufreq_frequency_table) | 626 | powernow_table = kmalloc((sizeof(*powernow_table) |
627 | * (data->numps + 1)), GFP_KERNEL); | 627 | * (data->numps + 1)), GFP_KERNEL); |
628 | if (!powernow_table) { | 628 | if (!powernow_table) { |
629 | printk(KERN_ERR PFX "powernow_table memory alloc failure\n"); | 629 | printk(KERN_ERR PFX "powernow_table memory alloc failure\n"); |
@@ -793,7 +793,7 @@ static int powernow_k8_cpu_init_acpi(struct powernow_k8_data *data) | |||
793 | } | 793 | } |
794 | 794 | ||
795 | /* fill in data->powernow_table */ | 795 | /* fill in data->powernow_table */ |
796 | powernow_table = kmalloc((sizeof(struct cpufreq_frequency_table) | 796 | powernow_table = kmalloc((sizeof(*powernow_table) |
797 | * (data->acpi_data.state_count + 1)), GFP_KERNEL); | 797 | * (data->acpi_data.state_count + 1)), GFP_KERNEL); |
798 | if (!powernow_table) { | 798 | if (!powernow_table) { |
799 | pr_debug("powernow_table memory alloc failure\n"); | 799 | pr_debug("powernow_table memory alloc failure\n"); |
@@ -1106,7 +1106,7 @@ static int powernowk8_cpu_init(struct cpufreq_policy *pol) | |||
1106 | if (rc) | 1106 | if (rc) |
1107 | return -ENODEV; | 1107 | return -ENODEV; |
1108 | 1108 | ||
1109 | data = kzalloc(sizeof(struct powernow_k8_data), GFP_KERNEL); | 1109 | data = kzalloc(sizeof(*data), GFP_KERNEL); |
1110 | if (!data) { | 1110 | if (!data) { |
1111 | printk(KERN_ERR PFX "unable to alloc powernow_k8_data"); | 1111 | printk(KERN_ERR PFX "unable to alloc powernow_k8_data"); |
1112 | return -ENOMEM; | 1112 | return -ENOMEM; |
@@ -1240,7 +1240,6 @@ static struct cpufreq_driver cpufreq_amd64_driver = { | |||
1240 | .exit = powernowk8_cpu_exit, | 1240 | .exit = powernowk8_cpu_exit, |
1241 | .get = powernowk8_get, | 1241 | .get = powernowk8_get, |
1242 | .name = "powernow-k8", | 1242 | .name = "powernow-k8", |
1243 | .owner = THIS_MODULE, | ||
1244 | .attr = powernow_k8_attr, | 1243 | .attr = powernow_k8_attr, |
1245 | }; | 1244 | }; |
1246 | 1245 | ||
diff --git a/drivers/cpufreq/ppc-corenet-cpufreq.c b/drivers/cpufreq/ppc-corenet-cpufreq.c index 3cae4529f959..60e81d524ea8 100644 --- a/drivers/cpufreq/ppc-corenet-cpufreq.c +++ b/drivers/cpufreq/ppc-corenet-cpufreq.c | |||
@@ -300,7 +300,6 @@ static struct freq_attr *corenet_cpufreq_attr[] = { | |||
300 | 300 | ||
301 | static struct cpufreq_driver ppc_corenet_cpufreq_driver = { | 301 | static struct cpufreq_driver ppc_corenet_cpufreq_driver = { |
302 | .name = "ppc_cpufreq", | 302 | .name = "ppc_cpufreq", |
303 | .owner = THIS_MODULE, | ||
304 | .flags = CPUFREQ_CONST_LOOPS, | 303 | .flags = CPUFREQ_CONST_LOOPS, |
305 | .init = corenet_cpufreq_cpu_init, | 304 | .init = corenet_cpufreq_cpu_init, |
306 | .exit = __exit_p(corenet_cpufreq_cpu_exit), | 305 | .exit = __exit_p(corenet_cpufreq_cpu_exit), |
diff --git a/drivers/cpufreq/ppc_cbe_cpufreq.c b/drivers/cpufreq/ppc_cbe_cpufreq.c index 5936f8d6f2cc..2e448f0bbdc5 100644 --- a/drivers/cpufreq/ppc_cbe_cpufreq.c +++ b/drivers/cpufreq/ppc_cbe_cpufreq.c | |||
@@ -181,7 +181,6 @@ static struct cpufreq_driver cbe_cpufreq_driver = { | |||
181 | .init = cbe_cpufreq_cpu_init, | 181 | .init = cbe_cpufreq_cpu_init, |
182 | .exit = cbe_cpufreq_cpu_exit, | 182 | .exit = cbe_cpufreq_cpu_exit, |
183 | .name = "cbe-cpufreq", | 183 | .name = "cbe-cpufreq", |
184 | .owner = THIS_MODULE, | ||
185 | .flags = CPUFREQ_CONST_LOOPS, | 184 | .flags = CPUFREQ_CONST_LOOPS, |
186 | }; | 185 | }; |
187 | 186 | ||
diff --git a/drivers/cpufreq/pxa2xx-cpufreq.c b/drivers/cpufreq/pxa2xx-cpufreq.c index fb3981ac829f..8749eaf18793 100644 --- a/drivers/cpufreq/pxa2xx-cpufreq.c +++ b/drivers/cpufreq/pxa2xx-cpufreq.c | |||
@@ -191,7 +191,7 @@ static int pxa_cpufreq_change_voltage(pxa_freqs_t *pxa_freq) | |||
191 | return ret; | 191 | return ret; |
192 | } | 192 | } |
193 | 193 | ||
194 | static __init void pxa_cpufreq_init_voltages(void) | 194 | static void __init pxa_cpufreq_init_voltages(void) |
195 | { | 195 | { |
196 | vcc_core = regulator_get(NULL, "vcc_core"); | 196 | vcc_core = regulator_get(NULL, "vcc_core"); |
197 | if (IS_ERR(vcc_core)) { | 197 | if (IS_ERR(vcc_core)) { |
@@ -207,7 +207,7 @@ static int pxa_cpufreq_change_voltage(pxa_freqs_t *pxa_freq) | |||
207 | return 0; | 207 | return 0; |
208 | } | 208 | } |
209 | 209 | ||
210 | static __init void pxa_cpufreq_init_voltages(void) { } | 210 | static void __init pxa_cpufreq_init_voltages(void) { } |
211 | #endif | 211 | #endif |
212 | 212 | ||
213 | static void find_freq_tables(struct cpufreq_frequency_table **freq_table, | 213 | static void find_freq_tables(struct cpufreq_frequency_table **freq_table, |
diff --git a/drivers/cpufreq/pxa3xx-cpufreq.c b/drivers/cpufreq/pxa3xx-cpufreq.c index 9c92ef032a9e..d26306fb00d2 100644 --- a/drivers/cpufreq/pxa3xx-cpufreq.c +++ b/drivers/cpufreq/pxa3xx-cpufreq.c | |||
@@ -213,10 +213,12 @@ static int pxa3xx_cpufreq_init(struct cpufreq_policy *policy) | |||
213 | policy->cur = policy->min = policy->max; | 213 | policy->cur = policy->min = policy->max; |
214 | 214 | ||
215 | if (cpu_is_pxa300() || cpu_is_pxa310()) | 215 | if (cpu_is_pxa300() || cpu_is_pxa310()) |
216 | ret = setup_freqs_table(policy, ARRAY_AND_SIZE(pxa300_freqs)); | 216 | ret = setup_freqs_table(policy, pxa300_freqs, |
217 | ARRAY_SIZE(pxa300_freqs)); | ||
217 | 218 | ||
218 | if (cpu_is_pxa320()) | 219 | if (cpu_is_pxa320()) |
219 | ret = setup_freqs_table(policy, ARRAY_AND_SIZE(pxa320_freqs)); | 220 | ret = setup_freqs_table(policy, pxa320_freqs, |
221 | ARRAY_SIZE(pxa320_freqs)); | ||
220 | 222 | ||
221 | if (ret) { | 223 | if (ret) { |
222 | pr_err("failed to setup frequency table\n"); | 224 | pr_err("failed to setup frequency table\n"); |
diff --git a/drivers/cpufreq/s3c2416-cpufreq.c b/drivers/cpufreq/s3c2416-cpufreq.c index ce5b9fca9c18..22dcb81ef9d0 100644 --- a/drivers/cpufreq/s3c2416-cpufreq.c +++ b/drivers/cpufreq/s3c2416-cpufreq.c | |||
@@ -524,7 +524,6 @@ static struct freq_attr *s3c2416_cpufreq_attr[] = { | |||
524 | }; | 524 | }; |
525 | 525 | ||
526 | static struct cpufreq_driver s3c2416_cpufreq_driver = { | 526 | static struct cpufreq_driver s3c2416_cpufreq_driver = { |
527 | .owner = THIS_MODULE, | ||
528 | .flags = 0, | 527 | .flags = 0, |
529 | .verify = s3c2416_cpufreq_verify_speed, | 528 | .verify = s3c2416_cpufreq_verify_speed, |
530 | .target = s3c2416_cpufreq_set_target, | 529 | .target = s3c2416_cpufreq_set_target, |
diff --git a/drivers/cpufreq/s3c24xx-cpufreq.c b/drivers/cpufreq/s3c24xx-cpufreq.c index 87781eb20d6d..b0f343fcb7ee 100644 --- a/drivers/cpufreq/s3c24xx-cpufreq.c +++ b/drivers/cpufreq/s3c24xx-cpufreq.c | |||
@@ -392,7 +392,7 @@ static int s3c_cpufreq_init(struct cpufreq_policy *policy) | |||
392 | return 0; | 392 | return 0; |
393 | } | 393 | } |
394 | 394 | ||
395 | static __init int s3c_cpufreq_initclks(void) | 395 | static int __init s3c_cpufreq_initclks(void) |
396 | { | 396 | { |
397 | _clk_mpll = s3c_cpufreq_clk_get(NULL, "mpll"); | 397 | _clk_mpll = s3c_cpufreq_clk_get(NULL, "mpll"); |
398 | _clk_xtal = s3c_cpufreq_clk_get(NULL, "xtal"); | 398 | _clk_xtal = s3c_cpufreq_clk_get(NULL, "xtal"); |
@@ -522,7 +522,7 @@ int __init s3c_cpufreq_setboard(struct s3c_cpufreq_board *board) | |||
522 | /* Copy the board information so that each board can make this | 522 | /* Copy the board information so that each board can make this |
523 | * initdata. */ | 523 | * initdata. */ |
524 | 524 | ||
525 | ours = kzalloc(sizeof(struct s3c_cpufreq_board), GFP_KERNEL); | 525 | ours = kzalloc(sizeof(*ours), GFP_KERNEL); |
526 | if (ours == NULL) { | 526 | if (ours == NULL) { |
527 | printk(KERN_ERR "%s: no memory\n", __func__); | 527 | printk(KERN_ERR "%s: no memory\n", __func__); |
528 | return -ENOMEM; | 528 | return -ENOMEM; |
@@ -615,7 +615,7 @@ static int s3c_cpufreq_build_freq(void) | |||
615 | size = cpu_cur.info->calc_freqtable(&cpu_cur, NULL, 0); | 615 | size = cpu_cur.info->calc_freqtable(&cpu_cur, NULL, 0); |
616 | size++; | 616 | size++; |
617 | 617 | ||
618 | ftab = kmalloc(sizeof(struct cpufreq_frequency_table) * size, GFP_KERNEL); | 618 | ftab = kmalloc(sizeof(*ftab) * size, GFP_KERNEL); |
619 | if (!ftab) { | 619 | if (!ftab) { |
620 | printk(KERN_ERR "%s: no memory for tables\n", __func__); | 620 | printk(KERN_ERR "%s: no memory for tables\n", __func__); |
621 | return -ENOMEM; | 621 | return -ENOMEM; |
@@ -691,7 +691,7 @@ int __init s3c_plltab_register(struct cpufreq_frequency_table *plls, | |||
691 | struct cpufreq_frequency_table *vals; | 691 | struct cpufreq_frequency_table *vals; |
692 | unsigned int size; | 692 | unsigned int size; |
693 | 693 | ||
694 | size = sizeof(struct cpufreq_frequency_table) * (plls_no + 1); | 694 | size = sizeof(*vals) * (plls_no + 1); |
695 | 695 | ||
696 | vals = kmalloc(size, GFP_KERNEL); | 696 | vals = kmalloc(size, GFP_KERNEL); |
697 | if (vals) { | 697 | if (vals) { |
diff --git a/drivers/cpufreq/s3c64xx-cpufreq.c b/drivers/cpufreq/s3c64xx-cpufreq.c index 13bb4bae64ee..8a72b0c555f8 100644 --- a/drivers/cpufreq/s3c64xx-cpufreq.c +++ b/drivers/cpufreq/s3c64xx-cpufreq.c | |||
@@ -263,7 +263,6 @@ static int s3c64xx_cpufreq_driver_init(struct cpufreq_policy *policy) | |||
263 | } | 263 | } |
264 | 264 | ||
265 | static struct cpufreq_driver s3c64xx_cpufreq_driver = { | 265 | static struct cpufreq_driver s3c64xx_cpufreq_driver = { |
266 | .owner = THIS_MODULE, | ||
267 | .flags = 0, | 266 | .flags = 0, |
268 | .verify = s3c64xx_cpufreq_verify_speed, | 267 | .verify = s3c64xx_cpufreq_verify_speed, |
269 | .target = s3c64xx_cpufreq_set_target, | 268 | .target = s3c64xx_cpufreq_set_target, |
diff --git a/drivers/cpufreq/sc520_freq.c b/drivers/cpufreq/sc520_freq.c index 77a210975fc4..d6f6c6f4efa7 100644 --- a/drivers/cpufreq/sc520_freq.c +++ b/drivers/cpufreq/sc520_freq.c | |||
@@ -147,7 +147,6 @@ static struct cpufreq_driver sc520_freq_driver = { | |||
147 | .init = sc520_freq_cpu_init, | 147 | .init = sc520_freq_cpu_init, |
148 | .exit = sc520_freq_cpu_exit, | 148 | .exit = sc520_freq_cpu_exit, |
149 | .name = "sc520_freq", | 149 | .name = "sc520_freq", |
150 | .owner = THIS_MODULE, | ||
151 | .attr = sc520_freq_attr, | 150 | .attr = sc520_freq_attr, |
152 | }; | 151 | }; |
153 | 152 | ||
diff --git a/drivers/cpufreq/sh-cpufreq.c b/drivers/cpufreq/sh-cpufreq.c index 73adb64651e8..ffc6d24b0cfb 100644 --- a/drivers/cpufreq/sh-cpufreq.c +++ b/drivers/cpufreq/sh-cpufreq.c | |||
@@ -160,7 +160,6 @@ static struct freq_attr *sh_freq_attr[] = { | |||
160 | }; | 160 | }; |
161 | 161 | ||
162 | static struct cpufreq_driver sh_cpufreq_driver = { | 162 | static struct cpufreq_driver sh_cpufreq_driver = { |
163 | .owner = THIS_MODULE, | ||
164 | .name = "sh", | 163 | .name = "sh", |
165 | .get = sh_cpufreq_get, | 164 | .get = sh_cpufreq_get, |
166 | .target = sh_cpufreq_target, | 165 | .target = sh_cpufreq_target, |
diff --git a/drivers/cpufreq/sparc-us2e-cpufreq.c b/drivers/cpufreq/sparc-us2e-cpufreq.c index 93061a408773..cf5bc2ca16fa 100644 --- a/drivers/cpufreq/sparc-us2e-cpufreq.c +++ b/drivers/cpufreq/sparc-us2e-cpufreq.c | |||
@@ -351,12 +351,11 @@ static int __init us2e_freq_init(void) | |||
351 | struct cpufreq_driver *driver; | 351 | struct cpufreq_driver *driver; |
352 | 352 | ||
353 | ret = -ENOMEM; | 353 | ret = -ENOMEM; |
354 | driver = kzalloc(sizeof(struct cpufreq_driver), GFP_KERNEL); | 354 | driver = kzalloc(sizeof(*driver), GFP_KERNEL); |
355 | if (!driver) | 355 | if (!driver) |
356 | goto err_out; | 356 | goto err_out; |
357 | 357 | ||
358 | us2e_freq_table = kzalloc( | 358 | us2e_freq_table = kzalloc((NR_CPUS * sizeof(*us2e_freq_table)), |
359 | (NR_CPUS * sizeof(struct us2e_freq_percpu_info)), | ||
360 | GFP_KERNEL); | 359 | GFP_KERNEL); |
361 | if (!us2e_freq_table) | 360 | if (!us2e_freq_table) |
362 | goto err_out; | 361 | goto err_out; |
@@ -366,7 +365,6 @@ static int __init us2e_freq_init(void) | |||
366 | driver->target = us2e_freq_target; | 365 | driver->target = us2e_freq_target; |
367 | driver->get = us2e_freq_get; | 366 | driver->get = us2e_freq_get; |
368 | driver->exit = us2e_freq_cpu_exit; | 367 | driver->exit = us2e_freq_cpu_exit; |
369 | driver->owner = THIS_MODULE, | ||
370 | strcpy(driver->name, "UltraSPARC-IIe"); | 368 | strcpy(driver->name, "UltraSPARC-IIe"); |
371 | 369 | ||
372 | cpufreq_us2e_driver = driver; | 370 | cpufreq_us2e_driver = driver; |
diff --git a/drivers/cpufreq/sparc-us3-cpufreq.c b/drivers/cpufreq/sparc-us3-cpufreq.c index 880ee293d61e..ac76b489979d 100644 --- a/drivers/cpufreq/sparc-us3-cpufreq.c +++ b/drivers/cpufreq/sparc-us3-cpufreq.c | |||
@@ -212,12 +212,11 @@ static int __init us3_freq_init(void) | |||
212 | struct cpufreq_driver *driver; | 212 | struct cpufreq_driver *driver; |
213 | 213 | ||
214 | ret = -ENOMEM; | 214 | ret = -ENOMEM; |
215 | driver = kzalloc(sizeof(struct cpufreq_driver), GFP_KERNEL); | 215 | driver = kzalloc(sizeof(*driver), GFP_KERNEL); |
216 | if (!driver) | 216 | if (!driver) |
217 | goto err_out; | 217 | goto err_out; |
218 | 218 | ||
219 | us3_freq_table = kzalloc( | 219 | us3_freq_table = kzalloc((NR_CPUS * sizeof(*us3_freq_table)), |
220 | (NR_CPUS * sizeof(struct us3_freq_percpu_info)), | ||
221 | GFP_KERNEL); | 220 | GFP_KERNEL); |
222 | if (!us3_freq_table) | 221 | if (!us3_freq_table) |
223 | goto err_out; | 222 | goto err_out; |
@@ -227,7 +226,6 @@ static int __init us3_freq_init(void) | |||
227 | driver->target = us3_freq_target; | 226 | driver->target = us3_freq_target; |
228 | driver->get = us3_freq_get; | 227 | driver->get = us3_freq_get; |
229 | driver->exit = us3_freq_cpu_exit; | 228 | driver->exit = us3_freq_cpu_exit; |
230 | driver->owner = THIS_MODULE, | ||
231 | strcpy(driver->name, "UltraSPARC-III"); | 229 | strcpy(driver->name, "UltraSPARC-III"); |
232 | 230 | ||
233 | cpufreq_us3_driver = driver; | 231 | cpufreq_us3_driver = driver; |
diff --git a/drivers/cpufreq/spear-cpufreq.c b/drivers/cpufreq/spear-cpufreq.c index c3efa7f2a908..19e364fa5955 100644 --- a/drivers/cpufreq/spear-cpufreq.c +++ b/drivers/cpufreq/spear-cpufreq.c | |||
@@ -18,7 +18,7 @@ | |||
18 | #include <linux/err.h> | 18 | #include <linux/err.h> |
19 | #include <linux/init.h> | 19 | #include <linux/init.h> |
20 | #include <linux/module.h> | 20 | #include <linux/module.h> |
21 | #include <linux/of.h> | 21 | #include <linux/of_device.h> |
22 | #include <linux/slab.h> | 22 | #include <linux/slab.h> |
23 | #include <linux/types.h> | 23 | #include <linux/types.h> |
24 | 24 | ||
@@ -223,7 +223,7 @@ static int spear_cpufreq_driver_init(void) | |||
223 | const __be32 *val; | 223 | const __be32 *val; |
224 | int cnt, i, ret; | 224 | int cnt, i, ret; |
225 | 225 | ||
226 | np = of_find_node_by_path("/cpus/cpu@0"); | 226 | np = of_cpu_device_node_get(0); |
227 | if (!np) { | 227 | if (!np) { |
228 | pr_err("No cpu node found"); | 228 | pr_err("No cpu node found"); |
229 | return -ENODEV; | 229 | return -ENODEV; |
diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c index 0915e712fbdc..f897d5105842 100644 --- a/drivers/cpufreq/speedstep-centrino.c +++ b/drivers/cpufreq/speedstep-centrino.c | |||
@@ -575,7 +575,6 @@ static struct cpufreq_driver centrino_driver = { | |||
575 | .target = centrino_target, | 575 | .target = centrino_target, |
576 | .get = get_cur_freq, | 576 | .get = get_cur_freq, |
577 | .attr = centrino_attr, | 577 | .attr = centrino_attr, |
578 | .owner = THIS_MODULE, | ||
579 | }; | 578 | }; |
580 | 579 | ||
581 | /* | 580 | /* |
diff --git a/drivers/cpufreq/speedstep-ich.c b/drivers/cpufreq/speedstep-ich.c index e2e5aa971452..5355abb69afc 100644 --- a/drivers/cpufreq/speedstep-ich.c +++ b/drivers/cpufreq/speedstep-ich.c | |||
@@ -378,7 +378,6 @@ static struct cpufreq_driver speedstep_driver = { | |||
378 | .init = speedstep_cpu_init, | 378 | .init = speedstep_cpu_init, |
379 | .exit = speedstep_cpu_exit, | 379 | .exit = speedstep_cpu_exit, |
380 | .get = speedstep_get, | 380 | .get = speedstep_get, |
381 | .owner = THIS_MODULE, | ||
382 | .attr = speedstep_attr, | 381 | .attr = speedstep_attr, |
383 | }; | 382 | }; |
384 | 383 | ||
diff --git a/drivers/cpufreq/speedstep-smi.c b/drivers/cpufreq/speedstep-smi.c index f5a6b70ee6c0..abfba4f731eb 100644 --- a/drivers/cpufreq/speedstep-smi.c +++ b/drivers/cpufreq/speedstep-smi.c | |||
@@ -375,7 +375,6 @@ static struct cpufreq_driver speedstep_driver = { | |||
375 | .exit = speedstep_cpu_exit, | 375 | .exit = speedstep_cpu_exit, |
376 | .get = speedstep_get, | 376 | .get = speedstep_get, |
377 | .resume = speedstep_resume, | 377 | .resume = speedstep_resume, |
378 | .owner = THIS_MODULE, | ||
379 | .attr = speedstep_attr, | 378 | .attr = speedstep_attr, |
380 | }; | 379 | }; |
381 | 380 | ||
diff --git a/drivers/cpufreq/unicore2-cpufreq.c b/drivers/cpufreq/unicore2-cpufreq.c index 12fc904d7dab..b225f04d8ae5 100644 --- a/drivers/cpufreq/unicore2-cpufreq.c +++ b/drivers/cpufreq/unicore2-cpufreq.c | |||
@@ -24,7 +24,7 @@ static struct cpufreq_driver ucv2_driver; | |||
24 | /* make sure that only the "userspace" governor is run | 24 | /* make sure that only the "userspace" governor is run |
25 | * -- anything else wouldn't make sense on this platform, anyway. | 25 | * -- anything else wouldn't make sense on this platform, anyway. |
26 | */ | 26 | */ |
27 | int ucv2_verify_speed(struct cpufreq_policy *policy) | 27 | static int ucv2_verify_speed(struct cpufreq_policy *policy) |
28 | { | 28 | { |
29 | if (policy->cpu) | 29 | if (policy->cpu) |
30 | return -EINVAL; | 30 | return -EINVAL; |