aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/cpufreq
diff options
context:
space:
mode:
authorViresh Kumar <viresh.kumar@linaro.org>2015-01-27 03:36:08 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2015-02-03 17:27:45 -0500
commitb4f0676fe20da6abe4577cf960862bed7a31647e (patch)
tree949518ef27c36a472170c0cbd571d438a7e6fee8 /drivers/cpufreq
parent1e63eaf0c45f0ac733ef2818cd93e3e9047ef1c5 (diff)
cpufreq: Create for_each_policy()
To make code more readable and less error prone, lets create a helper macro for iterating over all active policies. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/cpufreq')
-rw-r--r--drivers/cpufreq/cpufreq.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 158709418e21..baa238fbadc1 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -31,6 +31,12 @@
31#include <linux/tick.h> 31#include <linux/tick.h>
32#include <trace/events/power.h> 32#include <trace/events/power.h>
33 33
34/* Macros to iterate over lists */
35/* Iterate over online CPUs policies */
36static LIST_HEAD(cpufreq_policy_list);
37#define for_each_policy(__policy) \
38 list_for_each_entry(__policy, &cpufreq_policy_list, policy_list)
39
34/** 40/**
35 * The "cpufreq driver" - the arch- or hardware-dependent low 41 * The "cpufreq driver" - the arch- or hardware-dependent low
36 * level driver of CPUFreq support, and its spinlock. This lock 42 * level driver of CPUFreq support, and its spinlock. This lock
@@ -41,7 +47,6 @@ static DEFINE_PER_CPU(struct cpufreq_policy *, cpufreq_cpu_data);
41static DEFINE_PER_CPU(struct cpufreq_policy *, cpufreq_cpu_data_fallback); 47static DEFINE_PER_CPU(struct cpufreq_policy *, cpufreq_cpu_data_fallback);
42static DEFINE_RWLOCK(cpufreq_driver_lock); 48static DEFINE_RWLOCK(cpufreq_driver_lock);
43DEFINE_MUTEX(cpufreq_governor_lock); 49DEFINE_MUTEX(cpufreq_governor_lock);
44static LIST_HEAD(cpufreq_policy_list);
45 50
46/* This one keeps track of the previously set governor of a removed CPU */ 51/* This one keeps track of the previously set governor of a removed CPU */
47static DEFINE_PER_CPU(char[CPUFREQ_NAME_LEN], cpufreq_cpu_governor); 52static DEFINE_PER_CPU(char[CPUFREQ_NAME_LEN], cpufreq_cpu_governor);
@@ -1113,7 +1118,7 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif)
1113 1118
1114 /* Check if this cpu was hot-unplugged earlier and has siblings */ 1119 /* Check if this cpu was hot-unplugged earlier and has siblings */
1115 read_lock_irqsave(&cpufreq_driver_lock, flags); 1120 read_lock_irqsave(&cpufreq_driver_lock, flags);
1116 list_for_each_entry(policy, &cpufreq_policy_list, policy_list) { 1121 for_each_policy(policy) {
1117 if (cpumask_test_cpu(cpu, policy->related_cpus)) { 1122 if (cpumask_test_cpu(cpu, policy->related_cpus)) {
1118 read_unlock_irqrestore(&cpufreq_driver_lock, flags); 1123 read_unlock_irqrestore(&cpufreq_driver_lock, flags);
1119 ret = cpufreq_add_policy_cpu(policy, cpu, dev); 1124 ret = cpufreq_add_policy_cpu(policy, cpu, dev);
@@ -1647,7 +1652,7 @@ void cpufreq_suspend(void)
1647 1652
1648 pr_debug("%s: Suspending Governors\n", __func__); 1653 pr_debug("%s: Suspending Governors\n", __func__);
1649 1654
1650 list_for_each_entry(policy, &cpufreq_policy_list, policy_list) { 1655 for_each_policy(policy) {
1651 if (__cpufreq_governor(policy, CPUFREQ_GOV_STOP)) 1656 if (__cpufreq_governor(policy, CPUFREQ_GOV_STOP))
1652 pr_err("%s: Failed to stop governor for policy: %p\n", 1657 pr_err("%s: Failed to stop governor for policy: %p\n",
1653 __func__, policy); 1658 __func__, policy);
@@ -1681,7 +1686,7 @@ void cpufreq_resume(void)
1681 1686
1682 pr_debug("%s: Resuming Governors\n", __func__); 1687 pr_debug("%s: Resuming Governors\n", __func__);
1683 1688
1684 list_for_each_entry(policy, &cpufreq_policy_list, policy_list) { 1689 for_each_policy(policy) {
1685 if (cpufreq_driver->resume && cpufreq_driver->resume(policy)) 1690 if (cpufreq_driver->resume && cpufreq_driver->resume(policy))
1686 pr_err("%s: Failed to resume driver: %p\n", __func__, 1691 pr_err("%s: Failed to resume driver: %p\n", __func__,
1687 policy); 1692 policy);
@@ -2324,7 +2329,7 @@ static int cpufreq_boost_set_sw(int state)
2324 struct cpufreq_policy *policy; 2329 struct cpufreq_policy *policy;
2325 int ret = -EINVAL; 2330 int ret = -EINVAL;
2326 2331
2327 list_for_each_entry(policy, &cpufreq_policy_list, policy_list) { 2332 for_each_policy(policy) {
2328 freq_table = cpufreq_frequency_get_table(policy->cpu); 2333 freq_table = cpufreq_frequency_get_table(policy->cpu);
2329 if (freq_table) { 2334 if (freq_table) {
2330 ret = cpufreq_frequency_table_cpuinfo(policy, 2335 ret = cpufreq_frequency_table_cpuinfo(policy,