cpufreq: cached_resolved_idx can not be negative
authorViresh Kumar <viresh.kumar@linaro.org>
Thu, 30 Jul 2020 03:29:40 +0000 (08:59 +0530)
committerViresh Kumar <viresh.kumar@linaro.org>
Thu, 30 Jul 2020 06:10:16 +0000 (11:40 +0530)
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>
drivers/cpufreq/cpufreq.c
drivers/cpufreq/qcom-cpufreq-hw.c
include/linux/cpufreq.h

index 0128de3603dfc8ac59c4435c44fd5ca255b582a7..053d72e52a313c3b4afd93a9395e6a417c192ca6 100644 (file)
@@ -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);
index fa68fa8ebd95ef6b8d3f52e336dc715186e2b9e5..599818d387175792cb04c90c5dfa2c936bd404c3 100644 (file)
@@ -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;
index 3494f6763597e7992af3e2afaa74cee471ce96c3..540c3ea4eb3c4922f8d1d9fed4cb8c73a604522a 100644 (file)
@@ -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 */