diff options
author | Stratos Karafotis <stratosk@semaphore.gr> | 2014-04-25 16:15:23 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2014-04-29 18:05:31 -0400 |
commit | 27e289dce29764e488c1e13e9aa6950cad1f4aab (patch) | |
tree | 8904333726b188ff77958bfd293bfe789a88ac05 /include/linux/cpufreq.h | |
parent | d1db0eea852497762cab43b905b879dfcd3b8987 (diff) |
cpufreq: Introduce macros for cpufreq_frequency_table iteration
Many cpufreq drivers need to iterate over the cpufreq_frequency_table
for various tasks.
This patch introduces two macros which can be used for iteration over
cpufreq_frequency_table keeping a common coding style across drivers:
- cpufreq_for_each_entry: iterate over each entry of the table
- cpufreq_for_each_valid_entry: iterate over each entry that contains
a valid frequency.
It should have no functional changes.
Signed-off-by: Stratos Karafotis <stratosk@semaphore.gr>
Acked-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'include/linux/cpufreq.h')
-rw-r--r-- | include/linux/cpufreq.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index 5ae5100c1f24..77a5fa191502 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h | |||
@@ -468,6 +468,27 @@ struct cpufreq_frequency_table { | |||
468 | * order */ | 468 | * order */ |
469 | }; | 469 | }; |
470 | 470 | ||
471 | bool cpufreq_next_valid(struct cpufreq_frequency_table **pos); | ||
472 | |||
473 | /* | ||
474 | * cpufreq_for_each_entry - iterate over a cpufreq_frequency_table | ||
475 | * @pos: the cpufreq_frequency_table * to use as a loop cursor. | ||
476 | * @table: the cpufreq_frequency_table * to iterate over. | ||
477 | */ | ||
478 | |||
479 | #define cpufreq_for_each_entry(pos, table) \ | ||
480 | for (pos = table; pos->frequency != CPUFREQ_TABLE_END; pos++) | ||
481 | |||
482 | /* | ||
483 | * cpufreq_for_each_valid_entry - iterate over a cpufreq_frequency_table | ||
484 | * excluding CPUFREQ_ENTRY_INVALID frequencies. | ||
485 | * @pos: the cpufreq_frequency_table * to use as a loop cursor. | ||
486 | * @table: the cpufreq_frequency_table * to iterate over. | ||
487 | */ | ||
488 | |||
489 | #define cpufreq_for_each_valid_entry(pos, table) \ | ||
490 | for (pos = table; cpufreq_next_valid(&pos); pos++) | ||
491 | |||
471 | int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy, | 492 | int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy, |
472 | struct cpufreq_frequency_table *table); | 493 | struct cpufreq_frequency_table *table); |
473 | 494 | ||