diff mbox

[RESEND] cpufreq: Use list_is_last() to check last entry of the policy list

Message ID 1453876346-21869-1-git-send-email-ego@linux.vnet.ibm.com (mailing list archive)
State Accepted, archived
Delegated to: Rafael Wysocki
Headers show

Commit Message

Gautham R Shenoy Jan. 27, 2016, 6:32 a.m. UTC
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.

Cc: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Gautham R. Shenoy <ego@linux.vnet.ibm.com>
---
The earlier version one was based on an Juri's experimental branch. 
I have based this one on linux-pm.git linux-next branch.

 drivers/cpufreq/cpufreq.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Viresh Kumar Jan. 27, 2016, 6:36 a.m. UTC | #1
On 27-01-16, 12:02, Gautham R. Shenoy wrote:
> 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.
> 
> Cc: Viresh Kumar <viresh.kumar@linaro.org>
> Signed-off-by: Gautham R. Shenoy <ego@linux.vnet.ibm.com>
> ---
> The earlier version one was based on an Juri's experimental branch. 
> I have based this one on linux-pm.git linux-next branch.
> 
>  drivers/cpufreq/cpufreq.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index c35e7da..e979ec7 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -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;

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Rafael J. Wysocki Jan. 27, 2016, 10:55 p.m. UTC | #2
On Wednesday, January 27, 2016 12:06:11 PM Viresh Kumar wrote:
> On 27-01-16, 12:02, Gautham R. Shenoy wrote:
> > 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.
> > 
> > Cc: Viresh Kumar <viresh.kumar@linaro.org>
> > Signed-off-by: Gautham R. Shenoy <ego@linux.vnet.ibm.com>
> > ---
> > The earlier version one was based on an Juri's experimental branch. 
> > I have based this one on linux-pm.git linux-next branch.
> > 
> >  drivers/cpufreq/cpufreq.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> > index c35e7da..e979ec7 100644
> > --- a/drivers/cpufreq/cpufreq.c
> > +++ b/drivers/cpufreq/cpufreq.c
> > @@ -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;
> 
> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

Applied, thanks!

Rafael

--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index c35e7da..e979ec7 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -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;