diff mbox

cpufreq: skip invalid entries when searching the frequency

Message ID 20161010213813.22087-1-aaro.koskinen@iki.fi (mailing list archive)
State Superseded, archived
Delegated to: Rafael Wysocki
Headers show

Commit Message

Aaro Koskinen Oct. 10, 2016, 9:38 p.m. UTC
Skip invalid entries when searching the frequency. This fixes cpufreq
at least on loongson2 MIPS board.

Fixes: da0c6dc00c69 ("cpufreq: Handle sorted frequency tables more efficiently")
Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi>
---
 include/linux/cpufreq.h | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

Comments

Viresh Kumar Oct. 12, 2016, 3:16 a.m. UTC | #1
On 11-10-16, 00:38, Aaro Koskinen wrote:
> Skip invalid entries when searching the frequency. This fixes cpufreq
> at least on loongson2 MIPS board.
> 
> Fixes: da0c6dc00c69 ("cpufreq: Handle sorted frequency tables more efficiently")
> Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi>
> ---
>  include/linux/cpufreq.h | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)

Hi Aaro,

I have sent a new version of this patch, but screwed up the
--in-reply-to somehow.. Can you please give that a try?
diff mbox

Patch

diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index 631ba33b..0c1b188 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -645,6 +645,9 @@  static inline int cpufreq_table_find_index_al(struct cpufreq_policy *policy,
 	for (i = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) {
 		freq = table[i].frequency;
 
+		if (freq == CPUFREQ_ENTRY_INVALID)
+			continue;
+
 		if (freq >= target_freq)
 			return i;
 
@@ -665,6 +668,9 @@  static inline int cpufreq_table_find_index_dl(struct cpufreq_policy *policy,
 	for (i = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) {
 		freq = table[i].frequency;
 
+		if (freq == CPUFREQ_ENTRY_INVALID)
+			continue;
+
 		if (freq == target_freq)
 			return i;
 
@@ -706,6 +712,9 @@  static inline int cpufreq_table_find_index_ah(struct cpufreq_policy *policy,
 	for (i = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) {
 		freq = table[i].frequency;
 
+		if (freq == CPUFREQ_ENTRY_INVALID)
+			continue;
+
 		if (freq == target_freq)
 			return i;
 
@@ -735,6 +744,9 @@  static inline int cpufreq_table_find_index_dh(struct cpufreq_policy *policy,
 	for (i = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) {
 		freq = table[i].frequency;
 
+		if (freq == CPUFREQ_ENTRY_INVALID)
+			continue;
+
 		if (freq <= target_freq)
 			return i;
 
@@ -767,6 +779,9 @@  static inline int cpufreq_table_find_index_ac(struct cpufreq_policy *policy,
 	for (i = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) {
 		freq = table[i].frequency;
 
+		if (freq == CPUFREQ_ENTRY_INVALID)
+			continue;
+
 		if (freq == target_freq)
 			return i;
 
@@ -800,6 +815,9 @@  static inline int cpufreq_table_find_index_dc(struct cpufreq_policy *policy,
 	for (i = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) {
 		freq = table[i].frequency;
 
+		if (freq == CPUFREQ_ENTRY_INVALID)
+			continue;
+
 		if (freq == target_freq)
 			return i;