On 08-05-15, 23:46, Rafael J. Wysocki wrote:
On Friday, May 08, 2015 11:53:44 AM Viresh Kumar wrote:
+#define __for_each_active_policy(__policy, __temp, __active) \
- for (__temp = NULL, __policy = next_policy(NULL, __active); \
&__policy->policy_list != &cpufreq_policy_list || \
((__policy = __temp) && 0); \
__temp = __policy, __policy = next_policy(__policy, __active))
can be rewritten as:
#define __for_each_active_policy(__policy, __active) \ for (__policy = first_policy(__active); __policy; \ __policy = next_policy(__policy, __active))
and you don't need to explain what it does even. Of course, next_policy() has to return 'false' when it can't find anything suitable, but that shouldn't be too difficult to arrange I suppose?
Or if you need __temp because the object pointed to by __policy can go away, you can follow the design of list_for_each_entry_safe() here.
I wasn't using __temp to be safe, but to make sure that the loop points to a 'active' policy at the end. But that isn't required anymore as the only call site that required this, is fixed in a better way:
c75de0ac0756 ("cpufreq: Schedule work for the first-online CPU on resume")