Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cpufreq: conservative: Use an inline function to evaluate freq_target

Use an inline function to evaluate freq_target to avoid duplicate code.

Also, define a macro for the default frequency step.

Signed-off-by: Stratos Karafotis <stratosk@semaphore.gr>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Stratos Karafotis and committed by
Rafael J. Wysocki
98765847 cc721c4f

+16 -12
+16 -12
drivers/cpufreq/cpufreq_conservative.c
··· 29 29 /* Conservative governor macros */ 30 30 #define DEF_FREQUENCY_UP_THRESHOLD (80) 31 31 #define DEF_FREQUENCY_DOWN_THRESHOLD (20) 32 + #define DEF_FREQUENCY_STEP (5) 32 33 #define DEF_SAMPLING_DOWN_FACTOR (1) 33 34 #define MAX_SAMPLING_DOWN_FACTOR (10) 34 35 35 36 static DEFINE_PER_CPU(struct cs_cpu_dbs_info_s, cs_cpu_dbs_info); 37 + 38 + static inline unsigned int get_freq_target(struct cs_dbs_tuners *cs_tuners, 39 + struct cpufreq_policy *policy) 40 + { 41 + unsigned int freq_target = (cs_tuners->freq_step * policy->max) / 100; 42 + 43 + /* max freq cannot be less than 100. But who knows... */ 44 + if (unlikely(freq_target == 0)) 45 + freq_target = DEF_FREQUENCY_STEP; 46 + 47 + return freq_target; 48 + } 36 49 37 50 /* 38 51 * Every sampling_rate, we check, if current idle time is less than 20% ··· 62 49 struct cpufreq_policy *policy = dbs_info->cdbs.cur_policy; 63 50 struct dbs_data *dbs_data = policy->governor_data; 64 51 struct cs_dbs_tuners *cs_tuners = dbs_data->tuners; 65 - unsigned int freq_target; 66 52 67 53 /* 68 54 * break out if we 'cannot' reduce the speed as the user might ··· 78 66 if (dbs_info->requested_freq == policy->max) 79 67 return; 80 68 81 - freq_target = (cs_tuners->freq_step * policy->max) / 100; 82 - 83 - /* max freq cannot be less than 100. But who knows.... */ 84 - if (unlikely(freq_target == 0)) 85 - freq_target = 5; 86 - 87 - dbs_info->requested_freq += freq_target; 69 + dbs_info->requested_freq += get_freq_target(cs_tuners, policy); 88 70 if (dbs_info->requested_freq > policy->max) 89 71 dbs_info->requested_freq = policy->max; 90 72 ··· 100 94 if (policy->cur == policy->min) 101 95 return; 102 96 103 - freq_target = (cs_tuners->freq_step * policy->max) / 100; 104 - 105 - dbs_info->requested_freq -= freq_target; 97 + dbs_info->requested_freq -= get_freq_target(cs_tuners, policy); 106 98 if (dbs_info->requested_freq < policy->min) 107 99 dbs_info->requested_freq = policy->min; 108 100 ··· 339 335 tuners->down_threshold = DEF_FREQUENCY_DOWN_THRESHOLD; 340 336 tuners->sampling_down_factor = DEF_SAMPLING_DOWN_FACTOR; 341 337 tuners->ignore_nice = 0; 342 - tuners->freq_step = 5; 338 + tuners->freq_step = DEF_FREQUENCY_STEP; 343 339 344 340 dbs_data->tuners = tuners; 345 341 dbs_data->min_sampling_rate = MIN_SAMPLING_RATE_RATIO *