Skip to content

Commit

Permalink
cpufreq: Pass policy pointer to cpufreq_parse_governor()
Browse files Browse the repository at this point in the history
Pass policy pointer to cpufreq_parse_governor() instead of passing
pointers to two members of it so as to make the code slightly more
straightforward.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Rafael J. Wysocki committed Dec 4, 2017
1 parent 045149e commit ae0ff89
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions drivers/cpufreq/cpufreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -601,17 +601,17 @@ static struct cpufreq_governor *find_governor(const char *str_governor)
/**
* cpufreq_parse_governor - parse a governor string
*/
static int cpufreq_parse_governor(char *str_governor, unsigned int *policy,
struct cpufreq_governor **governor)
static int cpufreq_parse_governor(char *str_governor,
struct cpufreq_policy *policy)
{
if (cpufreq_driver->setpolicy) {
if (!strncasecmp(str_governor, "performance", CPUFREQ_NAME_LEN)) {
*policy = CPUFREQ_POLICY_PERFORMANCE;
policy->policy = CPUFREQ_POLICY_PERFORMANCE;
return 0;
}

if (!strncasecmp(str_governor, "powersave", CPUFREQ_NAME_LEN)) {
*policy = CPUFREQ_POLICY_POWERSAVE;
policy->policy = CPUFREQ_POLICY_POWERSAVE;
return 0;
}
} else {
Expand All @@ -637,7 +637,7 @@ static int cpufreq_parse_governor(char *str_governor, unsigned int *policy,
mutex_unlock(&cpufreq_governor_mutex);

if (t) {
*governor = t;
policy->governor = t;
return 0;
}
}
Expand Down Expand Up @@ -762,8 +762,7 @@ static ssize_t store_scaling_governor(struct cpufreq_policy *policy,
if (ret != 1)
return -EINVAL;

if (cpufreq_parse_governor(str_governor, &new_policy.policy,
&new_policy.governor))
if (cpufreq_parse_governor(str_governor, &new_policy))
return -EINVAL;

ret = cpufreq_set_policy(policy, &new_policy);
Expand Down Expand Up @@ -1046,8 +1045,7 @@ static int cpufreq_init_policy(struct cpufreq_policy *policy)
if (policy->last_policy)
new_policy.policy = policy->last_policy;
else
cpufreq_parse_governor(gov->name, &new_policy.policy,
NULL);
cpufreq_parse_governor(gov->name, &new_policy);
}
/* set default policy */
return cpufreq_set_policy(policy, &new_policy);
Expand Down

0 comments on commit ae0ff89

Please sign in to comment.