Skip to content

Commit 292072c

Browse files
committed
cpufreq: cached_resolved_idx can not be negative
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 <[email protected]>
1 parent df320f8 commit 292072c

File tree

3 files changed

+3
-6
lines changed

3 files changed

+3
-6
lines changed

drivers/cpufreq/cpufreq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ unsigned int cpufreq_driver_resolve_freq(struct cpufreq_policy *policy,
538538
policy->cached_target_freq = target_freq;
539539

540540
if (cpufreq_driver->target_index) {
541-
int idx;
541+
unsigned int idx;
542542

543543
idx = cpufreq_frequency_table_target(policy, target_freq,
544544
CPUFREQ_RELATION_L);

drivers/cpufreq/qcom-cpufreq-hw.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,10 @@ static unsigned int qcom_cpufreq_hw_fast_switch(struct cpufreq_policy *policy,
112112
unsigned int target_freq)
113113
{
114114
void __iomem *perf_state_reg = policy->driver_data;
115-
int index;
115+
unsigned int index;
116116
unsigned long freq;
117117

118118
index = policy->cached_resolved_idx;
119-
if (index < 0)
120-
return 0;
121-
122119
writel_relaxed(index, perf_state_reg);
123120

124121
freq = policy->freq_table[index].frequency;

include/linux/cpufreq.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ struct cpufreq_policy {
127127

128128
/* Cached frequency lookup from cpufreq_driver_resolve_freq. */
129129
unsigned int cached_target_freq;
130-
int cached_resolved_idx;
130+
unsigned int cached_resolved_idx;
131131

132132
/* Synchronization for frequency transitions */
133133
bool transition_ongoing; /* Tracks transition status */

0 commit comments

Comments
 (0)