cpufreq: Use list_is_last() to check last entry of the policy list
authorGautham R Shenoy <ego@linux.vnet.ibm.com>
Wed, 27 Jan 2016 06:32:26 +0000 (12:02 +0530)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 27 Jan 2016 22:13:59 +0000 (23:13 +0100)
Currently next_policy() explicitly checks if a policy is the last
policy in the cpufreq_policy_list. Use the standard list_is_last
primitive instead.

Signed-off-by: Gautham R. Shenoy <ego@linux.vnet.ibm.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/cpufreq/cpufreq.c

index c35e7da1ed7a185fd95d0f0ae7f7b2961d235a0f..e979ec78b69522edefb2a49b6497c2bbb83e1e62 100644 (file)
@@ -48,11 +48,11 @@ static struct cpufreq_policy *next_policy(struct cpufreq_policy *policy,
                                          bool active)
 {
        do {
-               policy = list_next_entry(policy, policy_list);
-
                /* No more policies in the list */
-               if (&policy->policy_list == &cpufreq_policy_list)
+               if (list_is_last(&policy->policy_list, &cpufreq_policy_list))
                        return NULL;
+
+               policy = list_next_entry(policy, policy_list);
        } while (!suitable_policy(policy, active));
 
        return policy;