Code cleanup and re-formatting
/arch/arm/mach-msm/msm_mpdecision.c
blob:9d067bd47cce47cb66a4716c8e4b24949bf225f0 -> blob:e076f41d46d66e10da99f82d468e2e2ca5ba1bc2
--- arch/arm/mach-msm/msm_mpdecision.c
+++ arch/arm/mach-msm/msm_mpdecision.c
@@ -37,11 +37,11 @@
#define DEBUG 0
-#define MPDEC_TAG "[AnThRaX MPDEC]: "
-#define MSM_MPDEC_STARTDELAY 20000
-#define MSM_MPDEC_DELAY 70
-#define MSM_MPDEC_PAUSE 10000
-#define MSM_MPDEC_IDLE_FREQ 486000
+#define MPDEC_TAG "[AnThRaX MPDEC]: "
+#define MSM_MPDEC_STARTDELAY 20000
+#define MSM_MPDEC_DELAY 70
+#define MSM_MPDEC_PAUSE 10000
+#define MSM_MPDEC_IDLE_FREQ 486000
enum {
MSM_MPDEC_DISABLED = 0,
@@ -68,16 +68,16 @@ static struct msm_mpdec_tuners {
unsigned int pause;
bool scroff_single_core;
unsigned long int idle_freq;
- unsigned int max_cpus;
- unsigned int min_cpus;
+ unsigned int max_cpus;
+ unsigned int min_cpus;
} msm_mpdec_tuners_ins = {
.startdelay = MSM_MPDEC_STARTDELAY,
.delay = MSM_MPDEC_DELAY,
.pause = MSM_MPDEC_PAUSE,
.scroff_single_core = true,
.idle_freq = MSM_MPDEC_IDLE_FREQ,
- .max_cpus = CONFIG_NR_CPUS,
- .min_cpus = 1,
+ .max_cpus = CONFIG_NR_CPUS,
+ .min_cpus = 1,
};
static unsigned int NwNs_Threshold[8] = {12, 0, 25, 20, 32, 28, 0, 35};
@@ -91,50 +91,47 @@ bool was_paused = false;
static unsigned long get_rate(int cpu)
{
- return acpuclk_get_rate(cpu);
+ return acpuclk_get_rate(cpu);
}
static int get_slowest_cpu(void)
{
- int i, cpu = 0;
- unsigned long rate, slow_rate = 0;
+ int i, cpu = 0;
+ unsigned long rate, slow_rate = 0;
- for (i = 1; i < CONFIG_NR_CPUS; i++) {
- if (!cpu_online(i))
- continue;
-
- rate = get_rate(i);
- if (slow_rate == 0) {
- slow_rate = rate;
- }
-
- if ((rate <= slow_rate) && (slow_rate != 0)) {
- cpu = i;
- slow_rate = rate;
- }
- }
+ for (i = 1; i < CONFIG_NR_CPUS; i++) {
+ if (!cpu_online(i))
+ continue;
+
+ rate = get_rate(i);
+ if (slow_rate == 0)
+ slow_rate = rate;
+
+ if ((rate <= slow_rate) && (slow_rate != 0)) {
+ cpu = i;
+ slow_rate = rate;
+ }
+ }
- return cpu;
+ return cpu;
}
static unsigned long get_slowest_cpu_rate(void)
{
- int i = 0;
- unsigned long rate, slow_rate = 0;
+ int i = 0;
+ unsigned long rate, slow_rate = 0;
- for (i = 0; i < CONFIG_NR_CPUS; i++) {
- if (!cpu_online(i))
- continue;
- rate = get_rate(i);
- if ((rate < slow_rate) && (slow_rate != 0)) {
- slow_rate = rate;
- }
- if (slow_rate == 0) {
- slow_rate = rate;
- }
- }
+ for (i = 0; i < CONFIG_NR_CPUS; i++) {
+ if (!cpu_online(i))
+ continue;
+ rate = get_rate(i);
+ if ((rate < slow_rate) && (slow_rate != 0))
+ slow_rate = rate;
+ if (slow_rate == 0)
+ slow_rate = rate;
+ }
- return slow_rate;
+ return slow_rate;
}
static int mp_decision(void)
@@ -169,18 +166,16 @@ static int mp_decision(void)
if (nr_cpu_online) {
index = (nr_cpu_online - 1) * 2;
if ((nr_cpu_online < CONFIG_NR_CPUS) && (rq_depth >= NwNs_Threshold[index])) {
- if ((total_time >= TwTs_Threshold[index]) &&
- (nr_cpu_online < msm_mpdec_tuners_ins.max_cpus)) {
+ if ((total_time >= TwTs_Threshold[index]) && (nr_cpu_online < msm_mpdec_tuners_ins.max_cpus)) {
new_state = MSM_MPDEC_UP;
- if (get_slowest_cpu_rate() <= msm_mpdec_tuners_ins.idle_freq)
- new_state = MSM_MPDEC_IDLE;
+ if (get_slowest_cpu_rate() <= msm_mpdec_tuners_ins.idle_freq)
+ new_state = MSM_MPDEC_IDLE;
}
} else if ((nr_cpu_online > 1) && (rq_depth <= NwNs_Threshold[index+1])) {
- if ((total_time >= TwTs_Threshold[index+1]) &&
- (nr_cpu_online > msm_mpdec_tuners_ins.min_cpus)) {
+ if ((total_time >= TwTs_Threshold[index+1]) && (nr_cpu_online > msm_mpdec_tuners_ins.min_cpus)) {
new_state = MSM_MPDEC_DOWN;
- if (get_slowest_cpu_rate() > msm_mpdec_tuners_ins.idle_freq)
- new_state = MSM_MPDEC_IDLE;
+ if (get_slowest_cpu_rate() > msm_mpdec_tuners_ins.idle_freq)
+ new_state = MSM_MPDEC_IDLE;
}
} else {
new_state = MSM_MPDEC_IDLE;
@@ -206,17 +201,17 @@ static void msm_mpdec_work_thread(struct
{
unsigned int cpu = nr_cpu_ids;
cputime64_t on_time = 0;
- bool suspended = false;
+ bool suspended = false;
- if (ktime_to_ms(ktime_get()) <= msm_mpdec_tuners_ins.startdelay)
- goto out;
+ if (ktime_to_ms(ktime_get()) <= msm_mpdec_tuners_ins.startdelay)
+ goto out;
- for_each_possible_cpu(cpu) {
- if ((per_cpu(msm_mpdec_cpudata, cpu).device_suspended == true)) {
- suspended = true;
- break;
- }
- }
+ for_each_possible_cpu(cpu) {
+ if ((per_cpu(msm_mpdec_cpudata, cpu).device_suspended == true)) {
+ suspended = true;
+ break;
+ }
+ }
if (suspended == true)
goto out;
@@ -300,18 +295,18 @@ static void msm_mpdec_early_suspend(stru
for_each_possible_cpu(cpu) {
mutex_lock(&per_cpu(msm_mpdec_cpudata, cpu).suspend_mutex);
if ((cpu >= 1) && (cpu_online(cpu))) {
- cpu_down(cpu);
- pr_info(MPDEC_TAG"Screen -> off. Suspended CPU[%d] | Mask=[%d%d%d%d]\n",
- cpu, cpu_online(0), cpu_online(1), cpu_online(2), cpu_online(3));
+ cpu_down(cpu);
+ pr_info(MPDEC_TAG"Screen -> off. Suspended CPU[%d] | Mask=[%d%d%d%d]\n",
+ cpu, cpu_online(0), cpu_online(1), cpu_online(2), cpu_online(3));
per_cpu(msm_mpdec_cpudata, cpu).online = false;
}
per_cpu(msm_mpdec_cpudata, cpu).device_suspended = true;
mutex_unlock(&per_cpu(msm_mpdec_cpudata, cpu).suspend_mutex);
}
- /* main work thread can sleep now */
- cancel_delayed_work_sync(&msm_mpdec_work);
+ /* main work thread can sleep now */
+ cancel_delayed_work_sync(&msm_mpdec_work);
- pr_info(MPDEC_TAG"Screen -> off. Deactivated mpdecision.\n");
+ pr_info(MPDEC_TAG"Screen -> off. Deactivated mpdecision.\n");
}
static void msm_mpdec_late_resume(struct early_suspend *h)
@@ -332,11 +327,11 @@ static void msm_mpdec_late_resume(struct
}
mutex_unlock(&per_cpu(msm_mpdec_cpudata, 1).suspend_mutex);
- /* wake up main work thread */
- was_paused = true;
- queue_delayed_work(msm_mpdec_workq, &msm_mpdec_work, 0);
+ /* wake up main work thread */
+ was_paused = true;
+ queue_delayed_work(msm_mpdec_workq, &msm_mpdec_work, 0);
- pr_info(MPDEC_TAG"Screen -> on. Activated mpdecision. | Mask=[%d%d%d%d]\n",
+ pr_info(MPDEC_TAG"Screen -> on. Activated mpdecision. | Mask=[%d%d%d%d]\n",
cpu_online(0), cpu_online(1), cpu_online(2), cpu_online(3));
}
@@ -546,7 +541,7 @@ static ssize_t store_max_cpus(struct kob
int ret;
ret = sscanf(buf, "%u", &input);
if ((ret != 1) || input > CONFIG_NR_CPUS)
- return -EINVAL;
+ return -EINVAL;
msm_mpdec_tuners_ins.max_cpus = input;
@@ -560,7 +555,7 @@ static ssize_t store_min_cpus(struct kob
int ret;
ret = sscanf(buf, "%u", &input);
if ((ret != 1) || input < 1)
- return -EINVAL;
+ return -EINVAL;
msm_mpdec_tuners_ins.min_cpus = input;
@@ -595,17 +590,17 @@ static ssize_t store_enabled(struct kobj
switch (buf[0]) {
case '0':
state = MSM_MPDEC_DISABLED;
- pr_info(MPDEC_TAG"nap time... Hot plugging offline CPUs...\n");
+ pr_info(MPDEC_TAG"nap time... Hot plugging offline CPUs...\n");
- for (cpu = 1; cpu < CONFIG_NR_CPUS; cpu++) {
- if (!cpu_online(cpu)) {
- per_cpu(msm_mpdec_cpudata, cpu).on_time = ktime_to_ms(ktime_get());
- per_cpu(msm_mpdec_cpudata, cpu).online = true;
- cpu_up(cpu);
- pr_info(MPDEC_TAG" DISABLED... Hot plugged CPU[%d] | Mask=[%d%d%d%d]\n",
- cpu, cpu_online(0), cpu_online(1), cpu_online(2), cpu_online(3));
- }
- }
+ for (cpu = 1; cpu < CONFIG_NR_CPUS; cpu++) {
+ if (!cpu_online(cpu)) {
+ per_cpu(msm_mpdec_cpudata, cpu).on_time = ktime_to_ms(ktime_get());
+ per_cpu(msm_mpdec_cpudata, cpu).online = true;
+ cpu_up(cpu);
+ pr_info(MPDEC_TAG" DISABLED... Hot plugged CPU[%d] | Mask=[%d%d%d%d]\n",
+ cpu, cpu_online(0), cpu_online(1), cpu_online(2), cpu_online(3));
+ }
+ }
break;
case '1':
state = MSM_MPDEC_IDLE;
@@ -635,8 +630,8 @@ static struct attribute *msm_mpdec_attri
&pause.attr,
&scroff_single_core.attr,
&idle_freq.attr,
- &min_cpus.attr,
- &max_cpus.attr,
+ &min_cpus.attr,
+ &max_cpus.attr,
&enabled.attr,
&twts_threshold_0.attr,
&twts_threshold_1.attr,
@@ -674,16 +669,16 @@ static int __init msm_mpdec_init(void)
per_cpu(msm_mpdec_cpudata, cpu).online = true;
}
- was_paused = true;
+ was_paused = true;
- msm_mpdec_workq = alloc_workqueue(
- "mpdec", WQ_UNBOUND | WQ_RESCUER | WQ_FREEZABLE, 1);
- if (!msm_mpdec_workq)
- return -ENOMEM;
+ msm_mpdec_workq = alloc_workqueue(
+ "mpdec", WQ_UNBOUND | WQ_RESCUER | WQ_FREEZABLE, 1);
+ if (!msm_mpdec_workq)
+ return -ENOMEM;
INIT_DELAYED_WORK(&msm_mpdec_work, msm_mpdec_work_thread);
if (state != MSM_MPDEC_DISABLED)
queue_delayed_work(msm_mpdec_workq, &msm_mpdec_work,
- msecs_to_jiffies(msm_mpdec_tuners_ins.delay));
+ msecs_to_jiffies(msm_mpdec_tuners_ins.delay));
register_early_suspend(&msm_mpdec_early_suspend_handler);
@@ -705,8 +700,8 @@ late_initcall(msm_mpdec_init);
void msm_mpdec_exit(void)
{
- destroy_workqueue(msm_mpdec_workq);
- destroy_workqueue(msm_mpdec_workq);
+ destroy_workqueue(msm_mpdec_workq);
+ destroy_workqueue(msm_mpdec_workq);
}
MODULE_DESCRIPTION("Kernel based MPDECISION (C) 2011-12 Chad Goodman");