aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2016-06-02 17:24:15 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2016-06-02 17:24:15 -0400
commite788892ba3cc71d385b75895f7a375fbc659ce86 (patch)
treef8a66153a91408f050eb7eb8d909c98d85a75ba9 /kernel
parenta92604b419f47e1c5098632742d8e031f6e8fab1 (diff)
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 'kernel')
-rw-r--r--kernel/sched/cpufreq_schedutil.c34
1 files changed, 8 insertions, 26 deletions
diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c
index 14c4aa25cc45..fdcee3cf38fc 100644
--- a/kernel/sched/cpufreq_schedutil.c
+++ b/kernel/sched/cpufreq_schedutil.c
@@ -394,7 +394,7 @@ static int sugov_init(struct cpufreq_policy *policy)
394 return ret; 394 return ret;
395} 395}
396 396
397static int sugov_exit(struct cpufreq_policy *policy) 397static void sugov_exit(struct cpufreq_policy *policy)
398{ 398{
399 struct sugov_policy *sg_policy = policy->governor_data; 399 struct sugov_policy *sg_policy = policy->governor_data;
400 struct sugov_tunables *tunables = sg_policy->tunables; 400 struct sugov_tunables *tunables = sg_policy->tunables;
@@ -412,7 +412,6 @@ static int sugov_exit(struct cpufreq_policy *policy)
412 mutex_unlock(&global_tunables_lock); 412 mutex_unlock(&global_tunables_lock);
413 413
414 sugov_policy_free(sg_policy); 414 sugov_policy_free(sg_policy);
415 return 0;
416} 415}
417 416
418static int sugov_start(struct cpufreq_policy *policy) 417static int sugov_start(struct cpufreq_policy *policy)
@@ -444,7 +443,7 @@ static int sugov_start(struct cpufreq_policy *policy)
444 return 0; 443 return 0;
445} 444}
446 445
447static int sugov_stop(struct cpufreq_policy *policy) 446static void sugov_stop(struct cpufreq_policy *policy)
448{ 447{
449 struct sugov_policy *sg_policy = policy->governor_data; 448 struct sugov_policy *sg_policy = policy->governor_data;
450 unsigned int cpu; 449 unsigned int cpu;
@@ -456,10 +455,9 @@ static int sugov_stop(struct cpufreq_policy *policy)
456 455
457 irq_work_sync(&sg_policy->irq_work); 456 irq_work_sync(&sg_policy->irq_work);
458 cancel_work_sync(&sg_policy->work); 457 cancel_work_sync(&sg_policy->work);
459 return 0;
460} 458}
461 459
462static int sugov_limits(struct cpufreq_policy *policy) 460static void sugov_limits(struct cpufreq_policy *policy)
463{ 461{
464 struct sugov_policy *sg_policy = policy->governor_data; 462 struct sugov_policy *sg_policy = policy->governor_data;
465 463
@@ -477,32 +475,16 @@ static int sugov_limits(struct cpufreq_policy *policy)
477 } 475 }
478 476
479 sg_policy->need_freq_update = true; 477 sg_policy->need_freq_update = true;
480 return 0;
481}
482
483int sugov_governor(struct cpufreq_policy *policy, unsigned int event)
484{
485 if (event == CPUFREQ_GOV_POLICY_INIT) {
486 return sugov_init(policy);
487 } else if (policy->governor_data) {
488 switch (event) {
489 case CPUFREQ_GOV_POLICY_EXIT:
490 return sugov_exit(policy);
491 case CPUFREQ_GOV_START:
492 return sugov_start(policy);
493 case CPUFREQ_GOV_STOP:
494 return sugov_stop(policy);
495 case CPUFREQ_GOV_LIMITS:
496 return sugov_limits(policy);
497 }
498 }
499 return -EINVAL;
500} 478}
501 479
502static struct cpufreq_governor schedutil_gov = { 480static struct cpufreq_governor schedutil_gov = {
503 .name = "schedutil", 481 .name = "schedutil",
504 .governor = sugov_governor,
505 .owner = THIS_MODULE, 482 .owner = THIS_MODULE,
483 .init = sugov_init,
484 .exit = sugov_exit,
485 .start = sugov_start,
486 .stop = sugov_stop,
487 .limits = sugov_limits,
506}; 488};
507 489
508static int __init sugov_module_init(void) 490static int __init sugov_module_init(void)