+- add patches.fixes/linux-post-2.6.3-20040220
[linux-flexiantxendom0-3.2.10.git] / include / linux / cpufreq.h
index bbc983d..3a8e279 100644 (file)
@@ -110,24 +110,24 @@ struct cpufreq_freqs {
  * @div:   divisor
  * @mult:  multiplier
  *
- * Needed for loops_per_jiffy and similar calculations.  We do it 
- * this way to avoid math overflow on 32-bit machines.  This will
- * become architecture dependent once high-resolution-timer is
- * merged (or any other thing that introduces sc_math.h).
  *
  *    new = old * mult / div
  */
 static inline unsigned long cpufreq_scale(unsigned long old, u_int div, u_int mult)
 {
-       unsigned long val, carry;
+#if BITS_PER_LONG == 32
 
-       mult /= 100;
-       div  /= 100;
-        val   = (old / div) * mult;
-        carry = old % div;
-       carry = carry * mult / div;
+       u64 result = ((u64) old) * ((u64) mult);
+       do_div(result, div);
+       return (unsigned long) result;
 
-       return carry + val;
+#elif BITS_PER_LONG == 64
+
+       unsigned long result = old * ((u64) mult);
+       result /= div;
+       return result;
+
+#endif
 };
 
 /*********************************************************************