Skip to content

Commit

Permalink
cpufreq: governor: Create cpufreq_policy_apply_limits()
Browse files Browse the repository at this point in the history
Create a new helper to avoid code duplication across governors.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Viresh Kumar authored and Rafael J. Wysocki committed Jun 2, 2016
1 parent 666f4cc commit bf2be2d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
7 changes: 1 addition & 6 deletions drivers/cpufreq/cpufreq_governor.c
Original file line number Diff line number Diff line change
Expand Up @@ -553,12 +553,7 @@ void cpufreq_dbs_governor_limits(struct cpufreq_policy *policy)
struct policy_dbs_info *policy_dbs = policy->governor_data;

mutex_lock(&policy_dbs->timer_mutex);

if (policy->max < policy->cur)
__cpufreq_driver_target(policy, policy->max, CPUFREQ_RELATION_H);
else if (policy->min > policy->cur)
__cpufreq_driver_target(policy, policy->min, CPUFREQ_RELATION_L);

cpufreq_policy_apply_limits(policy);
gov_update_sample_delay(policy_dbs, 0);

mutex_unlock(&policy_dbs->timer_mutex);
Expand Down
8 changes: 8 additions & 0 deletions include/linux/cpufreq.h
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,14 @@ void cpufreq_unregister_governor(struct cpufreq_governor *governor);
struct cpufreq_governor *cpufreq_default_governor(void);
struct cpufreq_governor *cpufreq_fallback_governor(void);

static inline void cpufreq_policy_apply_limits(struct cpufreq_policy *policy)
{
if (policy->max < policy->cur)
__cpufreq_driver_target(policy, policy->max, CPUFREQ_RELATION_H);
else if (policy->min > policy->cur)
__cpufreq_driver_target(policy, policy->min, CPUFREQ_RELATION_L);
}

/* Governor attribute set */
struct gov_attr_set {
struct kobject kobj;
Expand Down
9 changes: 1 addition & 8 deletions kernel/sched/cpufreq_schedutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -463,14 +463,7 @@ static void sugov_limits(struct cpufreq_policy *policy)

if (!policy->fast_switch_enabled) {
mutex_lock(&sg_policy->work_lock);

if (policy->max < policy->cur)
__cpufreq_driver_target(policy, policy->max,
CPUFREQ_RELATION_H);
else if (policy->min > policy->cur)
__cpufreq_driver_target(policy, policy->min,
CPUFREQ_RELATION_L);

cpufreq_policy_apply_limits(policy);
mutex_unlock(&sg_policy->work_lock);
}

Expand Down

0 comments on commit bf2be2d

Please sign in to comment.