- update to 2.6.1-rc2 -- first cut.
[linux-flexiantxendom0-3.2.10.git] / arch / i386 / kernel / cpu / cpufreq / longhaul.c
index c0dd4b2..24d06b6 100644 (file)
@@ -170,6 +170,9 @@ static void longhaul_setstate (unsigned int clock_ratio_index)
  * between that value multiplied by possible FSBs and cpu_mhz which
  * was calculated at boot time. Really ugly, but no other way to do this.
  */
+
+#define ROUNDING       0xf
+
 static int _guess (int guess, int maxmult)
 {
        int target;
@@ -177,16 +180,20 @@ static int _guess (int guess, int maxmult)
        target = ((maxmult/10)*guess);
        if (maxmult%10 != 0)
                target += (guess/2);
-       target &= ~0xf;
+       target += ROUNDING/2;
+       target &= ~ROUNDING;
        return target;
 }
 
 static int guess_fsb(int maxmult)
 {
-       int speed = (cpu_khz/1000) & ~0xf;
+       int speed = (cpu_khz/1000);
        int i;
        int speeds[3] = { 66, 100, 133 };
 
+       speed += ROUNDING/2;
+       speed &= ~ROUNDING;
+
        for (i=0; i<3; i++) {
                if (_guess(speeds[i],maxmult) == speed)
                        return speeds[i];