On 01/27/2015 12:36 AM, Viresh Kumar wrote:
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
drivers/cpufreq/cpufreq.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 72990ba59fad..9dfefb8ece6d 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -31,6 +31,12 @@ #include <linux/tick.h> #include <trace/events/power.h>
+/* Macros to iterate over lists */ +/* Iterate over online CPUs policies */ +static LIST_HEAD(cpufreq_policy_list); +#define for_each_policy(__policy) \
- list_for_each_entry(__policy, &cpufreq_policy_list, policy_list)
Could you "export" this macro/list so that it's usable by other clients of cpufreq too? If a driver wants to examine all the policies today, it has to do "for_each_cpu" and then try to get the policy for each CPU. This seems nicer.
-Saravana