summaryrefslogtreecommitdiffstats
path: root/drivers/cpufreq/freq_table.c
diff options
context:
space:
mode:
authorViresh Kumar <viresh.kumar@linaro.org>2016-06-03 10:58:51 +0530
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2016-06-09 00:58:06 +0200
commitd218ed773915a2b762d132be6bb765637338c360 (patch)
tree12e1e64d24fc80cbadff5285a439d441ed186c2f /drivers/cpufreq/freq_table.c
parent2372784542cb7a8b256a740840abf4503de0d669 (diff)
downloadlinux-d218ed773915a2b762d132be6bb765637338c360.tar.gz
linux-d218ed773915a2b762d132be6bb765637338c360.tar.bz2
linux-d218ed773915a2b762d132be6bb765637338c360.zip
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>
Diffstat (limited to 'drivers/cpufreq/freq_table.c')
-rw-r--r--drivers/cpufreq/freq_table.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c
index f145b64649ef..eac8bcbdaad1 100644
--- a/drivers/cpufreq/freq_table.c
+++ b/drivers/cpufreq/freq_table.c
@@ -114,9 +114,8 @@ int cpufreq_generic_frequency_table_verify(struct cpufreq_policy *policy)
EXPORT_SYMBOL_GPL(cpufreq_generic_frequency_table_verify);
int cpufreq_frequency_table_target(struct cpufreq_policy *policy,
- unsigned int target_freq,
- unsigned int relation,
- unsigned int *index)
+ unsigned int target_freq,
+ unsigned int relation)
{
struct cpufreq_frequency_table optimal = {
.driver_data = ~0,
@@ -129,6 +128,7 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy,
struct cpufreq_frequency_table *pos;
struct cpufreq_frequency_table *table = policy->freq_table;
unsigned int freq, diff, i = 0;
+ int index;
pr_debug("request for target %u kHz (relation: %u) for cpu %u\n",
target_freq, relation, policy->cpu);
@@ -192,16 +192,18 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy,
}
}
if (optimal.driver_data > i) {
- if (suboptimal.driver_data > i)
- return -EINVAL;
- *index = suboptimal.driver_data;
- } else
- *index = optimal.driver_data;
+ if (suboptimal.driver_data > i) {
+ WARN(1, "Invalid frequency table: %d\n", policy->cpu);
+ return 0;
+ }
- pr_debug("target index is %u, freq is:%u kHz\n", *index,
- table[*index].frequency);
+ index = suboptimal.driver_data;
+ } else
+ index = optimal.driver_data;
- return 0;
+ pr_debug("target index is %u, freq is:%u kHz\n", index,
+ table[index].frequency);
+ return index;
}
EXPORT_SYMBOL_GPL(cpufreq_frequency_table_target);