summaryrefslogtreecommitdiff
path: root/drivers/cpufreq/cpufreq.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2016-06-03 00:24:15 +0300
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2016-06-03 00:24:15 +0300
commite788892ba3cc71d385b75895f7a375fbc659ce86 (patch)
treef8a66153a91408f050eb7eb8d909c98d85a75ba9 /drivers/cpufreq/cpufreq.c
parenta92604b419f47e1c5098632742d8e031f6e8fab1 (diff)
downloadlinux-e788892ba3cc71d385b75895f7a375fbc659ce86.tar.xz
cpufreq: governor: Get rid of governor events
The design of the cpufreq governor API is not very straightforward, as struct cpufreq_governor provides only one callback to be invoked from different code paths for different purposes. The purpose it is invoked for is determined by its second "event" argument, causing it to act as a "callback multiplexer" of sorts. Unfortunately, that leads to extra complexity in governors, some of which implement the ->governor() callback as a switch statement that simply checks the event argument and invokes a separate function to handle that specific event. That extra complexity can be eliminated by replacing the all-purpose ->governor() callback with a family of callbacks to carry out specific governor operations: initialization and exit, start and stop and policy limits updates. That also turns out to reduce the code size too, so do it. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Diffstat (limited to 'drivers/cpufreq/cpufreq.c')
-rw-r--r--drivers/cpufreq/cpufreq.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 268566e40684..d98ff688b2f1 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -2023,10 +2023,12 @@ static int cpufreq_init_governor(struct cpufreq_policy *policy)
pr_debug("%s: for CPU %u\n", __func__, policy->cpu);
- ret = policy->governor->governor(policy, CPUFREQ_GOV_POLICY_INIT);
- if (ret) {
- module_put(policy->governor->owner);
- return ret;
+ if (policy->governor->init) {
+ ret = policy->governor->init(policy);
+ if (ret) {
+ module_put(policy->governor->owner);
+ return ret;
+ }
}
policy->governor->initialized++;
@@ -2040,7 +2042,8 @@ static void cpufreq_exit_governor(struct cpufreq_policy *policy)
pr_debug("%s: for CPU %u\n", __func__, policy->cpu);
- policy->governor->governor(policy, CPUFREQ_GOV_POLICY_EXIT);
+ if (policy->governor->exit)
+ policy->governor->exit(policy);
policy->governor->initialized--;
module_put(policy->governor->owner);
@@ -2061,11 +2064,15 @@ static int cpufreq_start_governor(struct cpufreq_policy *policy)
if (cpufreq_driver->get && !cpufreq_driver->setpolicy)
cpufreq_update_current_freq(policy);
- ret = policy->governor->governor(policy, CPUFREQ_GOV_START);
- if (ret)
- return ret;
+ if (policy->governor->start) {
+ ret = policy->governor->start(policy);
+ if (ret)
+ return ret;
+ }
+
+ if (policy->governor->limits)
+ policy->governor->limits(policy);
- policy->governor->governor(policy, CPUFREQ_GOV_LIMITS);
return 0;
}
@@ -2076,7 +2083,8 @@ static void cpufreq_stop_governor(struct cpufreq_policy *policy)
pr_debug("%s: for CPU %u\n", __func__, policy->cpu);
- policy->governor->governor(policy, CPUFREQ_GOV_STOP);
+ if (policy->governor->stop)
+ policy->governor->stop(policy);
}
static void cpufreq_governor_limits(struct cpufreq_policy *policy)
@@ -2086,7 +2094,8 @@ static void cpufreq_governor_limits(struct cpufreq_policy *policy)
pr_debug("%s: for CPU %u\n", __func__, policy->cpu);
- policy->governor->governor(policy, CPUFREQ_GOV_LIMITS);
+ if (policy->governor->limits)
+ policy->governor->limits(policy);
}
int cpufreq_register_governor(struct cpufreq_governor *governor)