]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/cpufreq/cpufreq_ondemand.c
[CPUFREQ] ondemand: add a check to avoid negative load calculation
[linux-2.6-omap-h63xx.git] / drivers / cpufreq / cpufreq_ondemand.c
index 8532bb79e5fc52dfc8d45ac3aba16b3f6ecd796f..dc6f357390e22c557018755cee756825c3b30eda 100644 (file)
@@ -325,7 +325,7 @@ static struct attribute_group dbs_attr_group = {
 static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info)
 {
        unsigned int idle_ticks, total_ticks;
-       unsigned int load;
+       unsigned int load = 0;
        cputime64_t cur_jiffies;
 
        struct cpufreq_policy *policy;
@@ -370,7 +370,8 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info)
                if (tmp_idle_ticks < idle_ticks)
                        idle_ticks = tmp_idle_ticks;
        }
-       load = (100 * (total_ticks - idle_ticks)) / total_ticks;
+       if (likely(total_ticks > idle_ticks))
+               load = (100 * (total_ticks - idle_ticks)) / total_ticks;
 
        /* Check for frequency increase */
        if (load > dbs_tuners_ins.up_threshold) {