aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/cpufreq/cpufreq.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2016-05-12 09:13:35 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2016-05-17 20:27:32 -0400
commit36be3418eb769c66bc16eb1c9b402591cf1219b7 (patch)
treef4ce2eab966b71b5644f79306e135cd9c52ff634 /drivers/cpufreq/cpufreq.c
parentc749c64f45fa07d20e11af2e3f3caa9d7650d341 (diff)
cpufreq: governor: CPUFREQ_GOV_POLICY_EXIT 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_POLICY_EXIT (unless invoked with incorrect arguments which doesn't matter anyway) and it wouldn't really make sense to fail it, because the caller won't be able to handle that failure in a meaningful way. 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>
Diffstat (limited to 'drivers/cpufreq/cpufreq.c')
-rw-r--r--drivers/cpufreq/cpufreq.c35
1 files changed, 12 insertions, 23 deletions
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 035513b012ee..74ab6f79145b 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -78,9 +78,9 @@ static int cpufreq_governor(struct cpufreq_policy *policy, unsigned int event);
78static unsigned int __cpufreq_get(struct cpufreq_policy *policy); 78static unsigned int __cpufreq_get(struct cpufreq_policy *policy);
79static int cpufreq_start_governor(struct cpufreq_policy *policy); 79static int cpufreq_start_governor(struct cpufreq_policy *policy);
80 80
81static inline int cpufreq_exit_governor(struct cpufreq_policy *policy) 81static inline void cpufreq_exit_governor(struct cpufreq_policy *policy)
82{ 82{
83 return cpufreq_governor(policy, CPUFREQ_GOV_POLICY_EXIT); 83 (void)cpufreq_governor(policy, CPUFREQ_GOV_POLICY_EXIT);
84} 84}
85 85
86/** 86/**
@@ -1387,12 +1387,8 @@ static void cpufreq_offline(unsigned int cpu)
1387 if (cpufreq_driver->stop_cpu) 1387 if (cpufreq_driver->stop_cpu)
1388 cpufreq_driver->stop_cpu(policy); 1388 cpufreq_driver->stop_cpu(policy);
1389 1389
1390 /* If cpu is last user of policy, free policy */ 1390 if (has_target())
1391 if (has_target()) { 1391 cpufreq_exit_governor(policy);
1392 ret = cpufreq_exit_governor(policy);
1393 if (ret)
1394 pr_err("%s: Failed to exit governor\n", __func__);
1395 }
1396 1392
1397 /* 1393 /*
1398 * Perform the ->exit() even during light-weight tear-down, 1394 * Perform the ->exit() even during light-weight tear-down,
@@ -2049,16 +2045,15 @@ static int cpufreq_governor(struct cpufreq_policy *policy, unsigned int event)
2049 2045
2050 ret = policy->governor->governor(policy, event); 2046 ret = policy->governor->governor(policy, event);
2051 2047
2052 if (!ret) { 2048 if (event == CPUFREQ_GOV_POLICY_INIT) {
2053 if (event == CPUFREQ_GOV_POLICY_INIT) 2049 if (ret)
2050 module_put(policy->governor->owner);
2051 else
2054 policy->governor->initialized++; 2052 policy->governor->initialized++;
2055 else if (event == CPUFREQ_GOV_POLICY_EXIT) 2053 } else if (event == CPUFREQ_GOV_POLICY_EXIT) {
2056 policy->governor->initialized--; 2054 policy->governor->initialized--;
2057 }
2058
2059 if (((event == CPUFREQ_GOV_POLICY_INIT) && ret) ||
2060 ((event == CPUFREQ_GOV_POLICY_EXIT) && !ret))
2061 module_put(policy->governor->owner); 2055 module_put(policy->governor->owner);
2056 }
2062 2057
2063 return ret; 2058 return ret;
2064} 2059}
@@ -2228,13 +2223,7 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy,
2228 __func__, old_gov->name, ret); 2223 __func__, old_gov->name, ret);
2229 return ret; 2224 return ret;
2230 } 2225 }
2231 2226 cpufreq_exit_governor(policy);
2232 ret = cpufreq_exit_governor(policy);
2233 if (ret) {
2234 pr_err("%s: Failed to Exit Governor: %s (%d)\n",
2235 __func__, old_gov->name, ret);
2236 return ret;
2237 }
2238 } 2227 }
2239 2228
2240 /* start new governor */ 2229 /* start new governor */