From 89b94c81c362d17fa45d8c48c5afebe2d7f1465f Mon Sep 17 00:00:00 2001 From: Alucard24 Date: Mon, 3 Oct 2016 16:09:13 +0200 Subject: [PATCH] alucard CPU governor: code optimization for function choose_target_freq. --- drivers/cpufreq/cpufreq_alucard.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/cpufreq/cpufreq_alucard.c b/drivers/cpufreq/cpufreq_alucard.c index 97354026e72..ffc54dd3493 100644 --- a/drivers/cpufreq/cpufreq_alucard.c +++ b/drivers/cpufreq/cpufreq_alucard.c @@ -212,8 +212,8 @@ static unsigned int choose_target_freq(struct cpufreq_alucard_policyinfo *pcpu, struct cpufreq_policy *policy = pcpu->policy; struct cpufreq_frequency_table *table = pcpu->freq_table; struct cpufreq_frequency_table *pos; - unsigned int i = 0, target_freq = 0, freq; - int count = 0; + unsigned int target_freq = 0, freq; + int i = 0, t = 0; if (!policy || !table || !step) return 0; @@ -224,19 +224,21 @@ static unsigned int choose_target_freq(struct cpufreq_alucard_policyinfo *pcpu, if (isup) { if (freq > policy->cur) { target_freq = freq; - count++; - if (count == step) + step--; + if (step == 0) { break; + } } } else { if (freq == policy->cur) { - for (count = (i - 1); count >= 0; count--) { - if (table[count].frequency != CPUFREQ_ENTRY_INVALID) { - target_freq = table[count].frequency; + for (t = (i - 1); t >= 0; t--) { + if (table[t].frequency != CPUFREQ_ENTRY_INVALID) { + target_freq = table[t].frequency; step--; + if (step == 0) { + break; + } } - if (step == 0) - break; } break; }