cpufreq: Return index from cpufreq_frequency_table_target()

This routine can't fail unless the frequency table is invalid and
doesn't contain any valid entries.

Make it return the index and WARN() in case it is used for an invalid
table.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
This commit is contained in:
Viresh Kumar
2016-06-03 10:58:51 +05:30
committed by Rafael J. Wysocki
parent 2372784542
commit d218ed7739
9 changed files with 37 additions and 61 deletions

View File

@@ -293,11 +293,8 @@ static int s3c_cpufreq_target(struct cpufreq_policy *policy,
__func__, policy, target_freq, relation);
if (ftab) {
if (cpufreq_frequency_table_target(policy, target_freq,
relation, &index)) {
s3c_freq_dbg("%s: table failed\n", __func__);
return -EINVAL;
}
index = cpufreq_frequency_table_target(policy, target_freq,
relation);
s3c_freq_dbg("%s: adjust %d to entry %d (%u)\n", __func__,
target_freq, index, ftab[index].frequency);
@@ -314,7 +311,6 @@ static int s3c_cpufreq_target(struct cpufreq_policy *policy,
pll = NULL;
} else {
struct cpufreq_policy tmp_policy;
int ret;
/* we keep the cpu pll table in Hz, to ensure we get an
* accurate value for the PLL output. */
@@ -324,18 +320,12 @@ static int s3c_cpufreq_target(struct cpufreq_policy *policy,
tmp_policy.cpu = policy->cpu;
tmp_policy.freq_table = pll_reg;
/* cpufreq_frequency_table_target uses a pointer to 'index'
* which is the number of the table entry, not the value of
/* cpufreq_frequency_table_target returns the index
* of the table entry, not the value of
* the table entry's index field. */
ret = cpufreq_frequency_table_target(&tmp_policy, target_freq,
relation, &index);
if (ret < 0) {
pr_err("%s: no PLL available\n", __func__);
goto err_notpossible;
}
index = cpufreq_frequency_table_target(&tmp_policy, target_freq,
relation);
pll = pll_reg + index;
s3c_freq_dbg("%s: target %u => %u\n",
@@ -345,10 +335,6 @@ static int s3c_cpufreq_target(struct cpufreq_policy *policy,
}
return s3c_cpufreq_settarget(policy, target_freq, pll);
err_notpossible:
pr_err("no compatible settings for %d\n", target_freq);
return -EINVAL;
}
struct clk *s3c_cpufreq_clk_get(struct device *dev, const char *name)