aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2016-05-12 09:14:12 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2016-05-17 20:28:29 -0400
commit45482c703b8c7e86e339e92f186cadd9a735fd0e (patch)
treebe5bbeab767ab58bfcb3362fd44533cac0e9d5b1
parent36be3418eb769c66bc16eb1c9b402591cf1219b7 (diff)
cpufreq: governor: CPUFREQ_GOV_STOP never fails
None of the cpufreq governors currently in the tree will ever fail an invocation of the ->governor() callback with the event argument equal to CPUFREQ_GOV_STOP (unless invoked with incorrect arguments which doesn't matter anyway) and it is rather difficult to imagine a valid reason for such a failure. Accordingly, rearrange the code in the core to make it clear that this call never fails. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
-rw-r--r--drivers/cpufreq/cpufreq.c40
1 files changed, 11 insertions, 29 deletions
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 74ab6f79145b..d199256d84c0 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -83,6 +83,11 @@ static inline void cpufreq_exit_governor(struct cpufreq_policy *policy)
83 (void)cpufreq_governor(policy, CPUFREQ_GOV_POLICY_EXIT); 83 (void)cpufreq_governor(policy, CPUFREQ_GOV_POLICY_EXIT);
84} 84}
85 85
86static inline void cpufreq_stop_governor(struct cpufreq_policy *policy)
87{
88 (void)cpufreq_governor(policy, CPUFREQ_GOV_STOP);
89}
90
86/** 91/**
87 * Two notifier lists: the "policy" list is involved in the 92 * Two notifier lists: the "policy" list is involved in the
88 * validation process for a new CPU frequency policy; the 93 * validation process for a new CPU frequency policy; the
@@ -1026,13 +1031,8 @@ static int cpufreq_add_policy_cpu(struct cpufreq_policy *policy, unsigned int cp
1026 return 0; 1031 return 0;
1027 1032
1028 down_write(&policy->rwsem); 1033 down_write(&policy->rwsem);
1029 if (has_target()) { 1034 if (has_target())
1030 ret = cpufreq_governor(policy, CPUFREQ_GOV_STOP); 1035 cpufreq_stop_governor(policy);
1031 if (ret) {
1032 pr_err("%s: Failed to stop governor\n", __func__);
1033 goto unlock;
1034 }
1035 }
1036 1036
1037 cpumask_set_cpu(cpu, policy->cpus); 1037 cpumask_set_cpu(cpu, policy->cpus);
1038 1038
@@ -1041,8 +1041,6 @@ static int cpufreq_add_policy_cpu(struct cpufreq_policy *policy, unsigned int cp
1041 if (ret) 1041 if (ret)
1042 pr_err("%s: Failed to start governor\n", __func__); 1042 pr_err("%s: Failed to start governor\n", __func__);
1043 } 1043 }
1044
1045unlock:
1046 up_write(&policy->rwsem); 1044 up_write(&policy->rwsem);
1047 return ret; 1045 return ret;
1048} 1046}
@@ -1354,11 +1352,8 @@ static void cpufreq_offline(unsigned int cpu)
1354 } 1352 }
1355 1353
1356 down_write(&policy->rwsem); 1354 down_write(&policy->rwsem);
1357 if (has_target()) { 1355 if (has_target())
1358 ret = cpufreq_governor(policy, CPUFREQ_GOV_STOP); 1356 cpufreq_stop_governor(policy);
1359 if (ret)
1360 pr_err("%s: Failed to stop governor\n", __func__);
1361 }
1362 1357
1363 cpumask_clear_cpu(cpu, policy->cpus); 1358 cpumask_clear_cpu(cpu, policy->cpus);
1364 1359
@@ -1622,7 +1617,6 @@ EXPORT_SYMBOL(cpufreq_generic_suspend);
1622void cpufreq_suspend(void) 1617void cpufreq_suspend(void)
1623{ 1618{
1624 struct cpufreq_policy *policy; 1619 struct cpufreq_policy *policy;
1625 int ret;
1626 1620
1627 if (!cpufreq_driver) 1621 if (!cpufreq_driver)
1628 return; 1622 return;
@@ -1635,14 +1629,8 @@ void cpufreq_suspend(void)
1635 for_each_active_policy(policy) { 1629 for_each_active_policy(policy) {
1636 if (has_target()) { 1630 if (has_target()) {
1637 down_write(&policy->rwsem); 1631 down_write(&policy->rwsem);
1638 ret = cpufreq_governor(policy, CPUFREQ_GOV_STOP); 1632 cpufreq_stop_governor(policy);
1639 up_write(&policy->rwsem); 1633 up_write(&policy->rwsem);
1640
1641 if (ret) {
1642 pr_err("%s: Failed to stop governor for policy: %p\n",
1643 __func__, policy);
1644 continue;
1645 }
1646 } 1634 }
1647 1635
1648 if (cpufreq_driver->suspend && cpufreq_driver->suspend(policy)) 1636 if (cpufreq_driver->suspend && cpufreq_driver->suspend(policy))
@@ -2216,13 +2204,7 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy,
2216 old_gov = policy->governor; 2204 old_gov = policy->governor;
2217 /* end old governor */ 2205 /* end old governor */
2218 if (old_gov) { 2206 if (old_gov) {
2219 ret = cpufreq_governor(policy, CPUFREQ_GOV_STOP); 2207 cpufreq_stop_governor(policy);
2220 if (ret) {
2221 /* This can happen due to race with other operations */
2222 pr_debug("%s: Failed to Stop Governor: %s (%d)\n",
2223 __func__, old_gov->name, ret);
2224 return ret;
2225 }
2226 cpufreq_exit_governor(policy); 2208 cpufreq_exit_governor(policy);
2227 } 2209 }
2228 2210