Skip to content

Commit

Permalink
cpufreq: cached_resolved_idx can not be negative
Browse files Browse the repository at this point in the history
It is not possible for cached_resolved_idx to be invalid here as the
cpufreq core always sets index to a positive value.

Change its type to unsigned int and fix qcom usage a bit.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
  • Loading branch information
Viresh Kumar committed Jul 30, 2020
1 parent df320f8 commit 292072c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
2 changes: 1 addition & 1 deletion drivers/cpufreq/cpufreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ unsigned int cpufreq_driver_resolve_freq(struct cpufreq_policy *policy,
policy->cached_target_freq = target_freq;

if (cpufreq_driver->target_index) {
int idx;
unsigned int idx;

idx = cpufreq_frequency_table_target(policy, target_freq,
CPUFREQ_RELATION_L);
Expand Down
5 changes: 1 addition & 4 deletions drivers/cpufreq/qcom-cpufreq-hw.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,10 @@ static unsigned int qcom_cpufreq_hw_fast_switch(struct cpufreq_policy *policy,
unsigned int target_freq)
{
void __iomem *perf_state_reg = policy->driver_data;
int index;
unsigned int index;
unsigned long freq;

index = policy->cached_resolved_idx;
if (index < 0)
return 0;

writel_relaxed(index, perf_state_reg);

freq = policy->freq_table[index].frequency;
Expand Down
2 changes: 1 addition & 1 deletion include/linux/cpufreq.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ struct cpufreq_policy {

/* Cached frequency lookup from cpufreq_driver_resolve_freq. */
unsigned int cached_target_freq;
int cached_resolved_idx;
unsigned int cached_resolved_idx;

/* Synchronization for frequency transitions */
bool transition_ongoing; /* Tracks transition status */
Expand Down

0 comments on commit 292072c

Please sign in to comment.