Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1343578 > unrolled thread

[PATCH] cpufreq: Simplify the cpufreq_for_each_valid_entry()

Started by"Rafael J. Wysocki" <rjw@rjwysocki.net>
First post2016-02-26 00:30 +0100
Last post2016-02-26 03:40 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] cpufreq: Simplify the cpufreq_for_each_valid_entry() "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-02-26 00:30 +0100
    Re: [PATCH] cpufreq: Simplify the cpufreq_for_each_valid_entry() Viresh Kumar <viresh.kumar@linaro.org> - 2016-02-26 03:40 +0100

#1343578 — [PATCH] cpufreq: Simplify the cpufreq_for_each_valid_entry()

From"Rafael J. Wysocki" <rjw@rjwysocki.net>
Date2016-02-26 00:30 +0100
Subject[PATCH] cpufreq: Simplify the cpufreq_for_each_valid_entry()
Message-ID<r6dw6-2Lc-19@gated-at.bofh.it>
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

That macro uses an internal static inline function that is first
totally unnecessary and second hard to read, so simplify it and
get rid of that monster.

No functional changes.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 include/linux/cpufreq.h |   17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

Index: linux-pm/include/linux/cpufreq.h
===================================================================
--- linux-pm.orig/include/linux/cpufreq.h
+++ linux-pm/include/linux/cpufreq.h
@@ -534,16 +534,6 @@ static inline void dev_pm_opp_free_cpufr
 }
 #endif
 
-static inline bool cpufreq_next_valid(struct cpufreq_frequency_table **pos)
-{
-	while ((*pos)->frequency != CPUFREQ_TABLE_END)
-		if ((*pos)->frequency != CPUFREQ_ENTRY_INVALID)
-			return true;
-		else
-			(*pos)++;
-	return false;
-}
-
 /*
  * cpufreq_for_each_entry -	iterate over a cpufreq_frequency_table
  * @pos:	the cpufreq_frequency_table * to use as a loop cursor.
@@ -560,8 +550,11 @@ static inline bool cpufreq_next_valid(st
  * @table:      the cpufreq_frequency_table * to iterate over.
  */
 
-#define cpufreq_for_each_valid_entry(pos, table)	\
-	for (pos = table; cpufreq_next_valid(&pos); pos++)
+#define cpufreq_for_each_valid_entry(pos, table)			\
+	for (pos = table; pos->frequency != CPUFREQ_TABLE_END; pos++)	\
+		if (pos->frequency == CPUFREQ_ENTRY_INVALID)		\
+			continue;					\
+		else
 
 int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy,
 				    struct cpufreq_frequency_table *table);

[toc] | [next] | [standalone]


#1343741

FromViresh Kumar <viresh.kumar@linaro.org>
Date2016-02-26 03:40 +0100
Message-ID<r6gtY-4Py-19@gated-at.bofh.it>
In reply to#1343578
On 26-02-16, 00:22, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> 
> That macro uses an internal static inline function that is first
> totally unnecessary and second hard to read, so simplify it and
> get rid of that monster.
> 
> No functional changes.
> 
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
>  include/linux/cpufreq.h |   17 +++++------------
>  1 file changed, 5 insertions(+), 12 deletions(-)
> 
> Index: linux-pm/include/linux/cpufreq.h
> ===================================================================
> --- linux-pm.orig/include/linux/cpufreq.h
> +++ linux-pm/include/linux/cpufreq.h
> @@ -534,16 +534,6 @@ static inline void dev_pm_opp_free_cpufr
>  }
>  #endif
>  
> -static inline bool cpufreq_next_valid(struct cpufreq_frequency_table **pos)
> -{
> -	while ((*pos)->frequency != CPUFREQ_TABLE_END)
> -		if ((*pos)->frequency != CPUFREQ_ENTRY_INVALID)
> -			return true;
> -		else
> -			(*pos)++;
> -	return false;
> -}
> -
>  /*
>   * cpufreq_for_each_entry -	iterate over a cpufreq_frequency_table
>   * @pos:	the cpufreq_frequency_table * to use as a loop cursor.
> @@ -560,8 +550,11 @@ static inline bool cpufreq_next_valid(st
>   * @table:      the cpufreq_frequency_table * to iterate over.
>   */
>  
> -#define cpufreq_for_each_valid_entry(pos, table)	\
> -	for (pos = table; cpufreq_next_valid(&pos); pos++)
> +#define cpufreq_for_each_valid_entry(pos, table)			\
> +	for (pos = table; pos->frequency != CPUFREQ_TABLE_END; pos++)	\
> +		if (pos->frequency == CPUFREQ_ENTRY_INVALID)		\
> +			continue;					\
> +		else
>  
>  int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy,
>  				    struct cpufreq_frequency_table *table);

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

-- 
viresh

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web