From ab20ea1c0024720f35b7dd0be11da1a87302cac0 Mon Sep 17 00:00:00 2001
From: Tuukka Tikkanen <idlestat@tic0.net>
Date: Thu, 12 Mar 2015 10:43:30 +0200
Subject: [PATCH] Fix merge_pstates

The function merge_pstates did not work as advertised. This patch fixes
the implementation.

Signed-off-by: Tuukka Tikkanen <idlestat@tic0.net>
---
 idlestat.c |   20 +++++---------------
 1 file changed, 5 insertions(+), 15 deletions(-)

diff --git a/idlestat.c b/idlestat.c
index 22a9781..4d773f4 100644
--- a/idlestat.c
+++ b/idlestat.c
@@ -696,21 +696,11 @@ static void merge_pstates(struct cpuidle_datas *datas,
 		percpu_a = &(datas->pstates[cpu]);
 		percpu_b = &(baseline->pstates[cpu]);
 
-		for (idx = 0; idx < percpu_a->max && idx < percpu_b->max; ) {
-			if (percpu_a->pstate[idx].freq >
-					percpu_b->pstate[idx].freq) {
-				assert(alloc_pstate(percpu_b,
-					percpu_a->pstate[idx].freq) == idx);
-				continue;
-			}
-			if (percpu_a->pstate[idx].freq <
-					percpu_b->pstate[idx].freq) {
-				assert(alloc_pstate(percpu_a,
-					percpu_b->pstate[idx].freq) == idx);
-				continue;
-			}
-			++idx;
-		}
+		for (idx = 0; idx < percpu_a->max; ++idx)
+			alloc_pstate(percpu_b, percpu_a->pstate[idx].freq);
+
+		for (idx = 0; idx < percpu_b->max; ++idx)
+			alloc_pstate(percpu_a, percpu_b->pstate[idx].freq);
 	}
 }
 
-- 
1.7.9.5

