cpufreq: interactive: Move cached_tunables into cpuinfo

Interactive governor already has a per_cpu field cpuinfo to keep track
of per_cpu data. Move cached_tunables into cpuinfo.

Change-Id: I77fda0cda76b56ff949456a95f96d129d877aa7b
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
diff --git a/drivers/cpufreq/cpufreq_interactive.c b/drivers/cpufreq/cpufreq_interactive.c
index d904682..bb71412 100644
--- a/drivers/cpufreq/cpufreq_interactive.c
+++ b/drivers/cpufreq/cpufreq_interactive.c
@@ -53,6 +53,7 @@
 	u64 loc_hispeed_val_time; /* per-cpu hispeed_validate_time */
 	struct rw_semaphore enable_sem;
 	int governor_enabled;
+	struct cpufreq_interactive_tunables *cached_tunables;
 };
 
 static DEFINE_PER_CPU(struct cpufreq_interactive_cpuinfo, cpuinfo);
@@ -140,7 +141,6 @@
 
 /* For cases where we have single governor instance for system */
 static struct cpufreq_interactive_tunables *common_tunables;
-static DEFINE_PER_CPU(struct cpufreq_interactive_tunables *, cached_tunables);
 
 static struct attribute_group *get_sysfs_attr(void);
 
@@ -1152,15 +1152,16 @@
 			  struct cpufreq_interactive_tunables *tunables)
 {
 	int cpu;
+	struct cpufreq_interactive_cpuinfo *pcpu;
 
 	if (have_governor_per_policy())
 		cpu = cpumask_first(policy->related_cpus);
 	else
 		cpu = 0;
 
-	WARN_ON(per_cpu(cached_tunables, cpu) &&
-		per_cpu(cached_tunables, cpu) != tunables);
-	per_cpu(cached_tunables, cpu) = tunables;
+	pcpu = &per_cpu(cpuinfo, cpu);
+	WARN_ON(pcpu->cached_tunables && pcpu->cached_tunables != tunables);
+	pcpu->cached_tunables = tunables;
 }
 
 static struct cpufreq_interactive_tunables *restore_tunables(
@@ -1173,7 +1174,7 @@
 	else
 		cpu = 0;
 
-	return per_cpu(cached_tunables, cpu);
+	return per_cpu(cpuinfo, cpu).cached_tunables;
 }
 
 static int cpufreq_governor_interactive(struct cpufreq_policy *policy,
@@ -1383,14 +1384,16 @@
 static void __exit cpufreq_interactive_exit(void)
 {
 	int cpu;
+	struct cpufreq_interactive_cpuinfo *pcpu;
 
 	cpufreq_unregister_governor(&cpufreq_gov_interactive);
 	kthread_stop(speedchange_task);
 	put_task_struct(speedchange_task);
 
 	for_each_possible_cpu(cpu) {
-		kfree(per_cpu(cached_tunables, cpu));
-		per_cpu(cached_tunables, cpu) = NULL;
+		pcpu = &per_cpu(cpuinfo, cpu);
+		kfree(pcpu->cached_tunables);
+		pcpu->cached_tunables = NULL;
 	}
 }