diff options
author | Viresh Kumar <viresh.kumar@linaro.org> | 2015-01-27 03:36:09 -0500 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2015-02-03 17:28:01 -0500 |
commit | f7b2706117bc4459cd748352cbe4ae69a41c8ed6 (patch) | |
tree | 2ce6b30de221cff2f149fa7f108d74c53ec7dc22 /drivers/cpufreq/cpufreq.c | |
parent | b4f0676fe20da6abe4577cf960862bed7a31647e (diff) |
cpufreq: Create for_each_governor()
To make code more readable and less error prone, lets create a helper macro for
iterating over all available governors.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Saravana Kannan <skannan@codeaurora.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/cpufreq/cpufreq.c')
-rw-r--r-- | drivers/cpufreq/cpufreq.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index baa238fbadc1..28e59a48b35f 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c | |||
@@ -37,6 +37,11 @@ static LIST_HEAD(cpufreq_policy_list); | |||
37 | #define for_each_policy(__policy) \ | 37 | #define for_each_policy(__policy) \ |
38 | list_for_each_entry(__policy, &cpufreq_policy_list, policy_list) | 38 | list_for_each_entry(__policy, &cpufreq_policy_list, policy_list) |
39 | 39 | ||
40 | /* Iterate over governors */ | ||
41 | static LIST_HEAD(cpufreq_governor_list); | ||
42 | #define for_each_governor(__governor) \ | ||
43 | list_for_each_entry(__governor, &cpufreq_governor_list, governor_list) | ||
44 | |||
40 | /** | 45 | /** |
41 | * The "cpufreq driver" - the arch- or hardware-dependent low | 46 | * The "cpufreq driver" - the arch- or hardware-dependent low |
42 | * level driver of CPUFreq support, and its spinlock. This lock | 47 | * level driver of CPUFreq support, and its spinlock. This lock |
@@ -99,7 +104,6 @@ void disable_cpufreq(void) | |||
99 | { | 104 | { |
100 | off = 1; | 105 | off = 1; |
101 | } | 106 | } |
102 | static LIST_HEAD(cpufreq_governor_list); | ||
103 | static DEFINE_MUTEX(cpufreq_governor_mutex); | 107 | static DEFINE_MUTEX(cpufreq_governor_mutex); |
104 | 108 | ||
105 | bool have_governor_per_policy(void) | 109 | bool have_governor_per_policy(void) |
@@ -434,7 +438,7 @@ static struct cpufreq_governor *find_governor(const char *str_governor) | |||
434 | { | 438 | { |
435 | struct cpufreq_governor *t; | 439 | struct cpufreq_governor *t; |
436 | 440 | ||
437 | list_for_each_entry(t, &cpufreq_governor_list, governor_list) | 441 | for_each_governor(t) |
438 | if (!strncasecmp(str_governor, t->name, CPUFREQ_NAME_LEN)) | 442 | if (!strncasecmp(str_governor, t->name, CPUFREQ_NAME_LEN)) |
439 | return t; | 443 | return t; |
440 | 444 | ||
@@ -636,7 +640,7 @@ static ssize_t show_scaling_available_governors(struct cpufreq_policy *policy, | |||
636 | goto out; | 640 | goto out; |
637 | } | 641 | } |
638 | 642 | ||
639 | list_for_each_entry(t, &cpufreq_governor_list, governor_list) { | 643 | for_each_governor(t) { |
640 | if (i >= (ssize_t) ((PAGE_SIZE / sizeof(char)) | 644 | if (i >= (ssize_t) ((PAGE_SIZE / sizeof(char)) |
641 | - (CPUFREQ_NAME_LEN + 2))) | 645 | - (CPUFREQ_NAME_LEN + 2))) |
642 | goto out; | 646 | goto out; |