Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=46ef955f5c9de0507859a3f9a92989b7425b73cc
Commit:     46ef955f5c9de0507859a3f9a92989b7425b73cc
Parent:     0d44b2ba287ea98547097ad2b8b0cc5f0589b8d2
Author:     Rafa� Bilski <[EMAIL PROTECTED]>
AuthorDate: Sun Feb 4 15:58:46 2007 +0100
Committer:  Dave Jones <[EMAIL PROTECTED]>
CommitDate: Sun Feb 4 18:09:19 2007 -0500

    [CPUFREQ] Longhaul - Fix guess_fsb function
    
    This is bug reported by John-Marc Chandonia:
    > Detected 1002.292 MHz processor.
    > longhaul: VIA C3 'Nehemiah B' [C5N] CPU detected.  Powersaver supported.
    > longhaul: Using throttling support.
    > longhaul: Invalid (reserved) FSB!
    FSB is correcly guessed for 999.554 MHz CPU.
    To fix this error:
    - ROUNDING should be range, not mask - at it's current value it is +7 -8,
    - more precise calculations inside guess_fsb - 7.5x133MHz is 1000MHz now.
    
    Signed-off-by: Rafal Bilski <[EMAIL PROTECTED]>
    Signed-off-by: Dave Jones <[EMAIL PROTECTED]>
---
 arch/i386/kernel/cpu/cpufreq/longhaul.c |   32 +++++++++---------------------
 1 files changed, 10 insertions(+), 22 deletions(-)

diff --git a/arch/i386/kernel/cpu/cpufreq/longhaul.c 
b/arch/i386/kernel/cpu/cpufreq/longhaul.c
index 8ea34e9..8b5ad30 100644
--- a/arch/i386/kernel/cpu/cpufreq/longhaul.c
+++ b/arch/i386/kernel/cpu/cpufreq/longhaul.c
@@ -318,31 +318,19 @@ static void longhaul_setstate(unsigned int 
clock_ratio_index)
 
 #define ROUNDING       0xf
 
-static int _guess(int guess, int mult)
-{
-       int target;
-
-       target = ((mult/10)*guess);
-       if (mult%10 != 0)
-               target += (guess/2);
-       target += ROUNDING/2;
-       target &= ~ROUNDING;
-       return target;
-}
-
-
 static int guess_fsb(int mult)
 {
-       int speed = (cpu_khz/1000);
+       int speed = cpu_khz / 1000;
        int i;
-       int speeds[] = { 66, 100, 133, 200 };
-
-       speed += ROUNDING/2;
-       speed &= ~ROUNDING;
-
-       for (i=0; i<4; i++) {
-               if (_guess(speeds[i], mult) == speed)
-                       return speeds[i];
+       int speeds[] = { 666, 1000, 1333, 2000 };
+       int f_max, f_min;
+
+       for (i = 0; i < 4; i++) {
+               f_max = ((speeds[i] * mult) + 50) / 100;
+               f_max += (ROUNDING / 2);
+               f_min = f_max - ROUNDING;
+               if ((speed <= f_max) && (speed >= f_min))
+                       return speeds[i] / 10;
        }
        return 0;
 }
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to