#include <linux/spinlock.h>
#include <linux/notifier.h>
#include <asm/cputime.h>
+#ifdef CONFIG_BL_SWITCHER
#include <asm/bL_switcher.h>
+#endif
static spinlock_t cpufreq_stats_lock;
return 0;
}
+static int cpufreq_stats_create_table_cpu(unsigned int cpu)
+{
+ struct cpufreq_policy *policy;
+ struct cpufreq_frequency_table *table;
+ int ret = -ENODEV;
+
+ policy = cpufreq_cpu_get(cpu);
+ if (!policy)
+ return -ENODEV;
+
+ table = cpufreq_frequency_get_table(cpu);
+ if (!table)
+ goto out;
+
+ ret = cpufreq_stats_create_table(policy, table);
+
+out:
+ cpufreq_cpu_put(policy);
+ return ret;
+}
+
static int __cpuinit cpufreq_stat_cpu_callback(struct notifier_block *nfb,
unsigned long action,
void *hcpu)
case CPU_DEAD_FROZEN:
cpufreq_stats_free_table(cpu);
break;
+ case CPU_DOWN_FAILED:
+ case CPU_DOWN_FAILED_FROZEN:
+ cpufreq_stats_create_table_cpu(cpu);
+ break;
}
return NOTIFY_OK;
}
}
}
+#ifdef CONFIG_BL_SWITCHER
static int cpufreq_stats_switcher_notifier(struct notifier_block *nfb,
unsigned long action, void *_arg)
{
static struct notifier_block switcher_notifier = {
.notifier_call = cpufreq_stats_switcher_notifier,
};
+#endif
static int __init cpufreq_stats_init(void)
{
spin_lock_init(&cpufreq_stats_lock);
ret = cpufreq_stats_setup();
+#ifdef CONFIG_BL_SWITCHER
if (!ret)
bL_switcher_register_notifier(&switcher_notifier);
-
+#endif
return ret;
}
static void __exit cpufreq_stats_exit(void)
{
+#ifdef CONFIG_BL_SWITCHER
bL_switcher_unregister_notifier(&switcher_notifier);
+#endif
cpufreq_stats_cleanup();
}