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 /Documentation/cpu-freq | |
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 'Documentation/cpu-freq')
-rw-r--r-- | Documentation/cpu-freq/cpu-drivers.txt | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Documentation/cpu-freq/cpu-drivers.txt b/Documentation/cpu-freq/cpu-drivers.txt index 48da5fdcb9f1..b045fe54986a 100644 --- a/Documentation/cpu-freq/cpu-drivers.txt +++ b/Documentation/cpu-freq/cpu-drivers.txt | |||
@@ -228,3 +228,22 @@ is the corresponding frequency table helper for the ->target | |||
228 | stage. Just pass the values to this function, and the unsigned int | 228 | stage. Just pass the values to this function, and the unsigned int |
229 | index returns the number of the frequency table entry which contains | 229 | index returns the number of the frequency table entry which contains |
230 | the frequency the CPU shall be set to. | 230 | the frequency the CPU shall be set to. |
231 | |||
232 | The following macros can be used as iterators over cpufreq_frequency_table: | ||
233 | |||
234 | cpufreq_for_each_entry(pos, table) - iterates over all entries of frequency | ||
235 | table. | ||
236 | |||
237 | cpufreq-for_each_valid_entry(pos, table) - iterates over all entries, | ||
238 | excluding CPUFREQ_ENTRY_INVALID frequencies. | ||
239 | Use arguments "pos" - a cpufreq_frequency_table * as a loop cursor and | ||
240 | "table" - the cpufreq_frequency_table * you want to iterate over. | ||
241 | |||
242 | For example: | ||
243 | |||
244 | struct cpufreq_frequency_table *pos, *driver_freq_table; | ||
245 | |||
246 | cpufreq_for_each_entry(pos, driver_freq_table) { | ||
247 | /* Do something with pos */ | ||
248 | pos->frequency = ... | ||
249 | } | ||