Hello,

I've just tested powersave version 0.11.0 and found a bug in cpufreq_userspace. The read_line function returns a boolean and the test was " < 0", witch is always false. Same for getMinMaxSpeeds.

I've also added a computation for speed steps (in initFreqsViaTesting) instead of the hardcoded value of 25 Mhz. With that, powersave is able to use the full range of frequencies on my computer, from 1.3GHz to 2GHz. I'm using cpufreq_nforce2, witch doesn't provide a list of available frequencies.

The patch is against version 0.11.0, not svn, but it sould apply.

Benoît.

diff -burN powersave-0.11.0.orig/daemon/cpufreq.h 
powersave-0.11.0/daemon/cpufreq.h
--- powersave-0.11.0.orig/daemon/cpufreq.h      2005-11-28 10:53:57.000000000 
+0100
+++ powersave-0.11.0/daemon/cpufreq.h   2005-12-15 23:44:04.000000000 +0100
@@ -33,6 +33,7 @@
    cpufreq.cc -> getspeeds() */
 
 #define MAX_SPEEDS  20
+#define MIN_SPEED_STEP 25000   /* in kHz, minimum step between 2 speeds */
 #define SYSFS_FILES \
     "/sys/devices/system/cpu/"
 
diff -burN powersave-0.11.0.orig/daemon/cpufreq_userspace.cpp 
powersave-0.11.0/daemon/cpufreq_userspace.cpp
--- powersave-0.11.0.orig/daemon/cpufreq_userspace.cpp  2005-11-21 
15:41:18.000000000 +0100
+++ powersave-0.11.0/daemon/cpufreq_userspace.cpp       2005-12-15 
23:35:53.000000000 +0100
@@ -331,7 +331,7 @@
        char speeds_line[MAX_LINE_SIZE + 1];
        char *temp;
 
-       if (read_line(AVAILABLE_FREQS_FILE.c_str(), speeds_line, MAX_LINE_SIZE) 
< 0)
+       if (read_line(AVAILABLE_FREQS_FILE.c_str(), speeds_line, MAX_LINE_SIZE) 
== false)
                return -1;
        temp = speeds_line;
        len = strlen(speeds_line);
@@ -376,13 +376,16 @@
 {
        unsigned int min, max;
 
-       if (getMinMaxSpeeds(&min, &max) < 0) {
+       if (getMinMaxSpeeds(&min, &max) == false) {
                /* Place this somewhere else where we could get out */
                pDebug(DBG_WARN, "Could not read min and max speed");
                return -1;
        }
        // initialise speed steps that can be set
-       const unsigned step = 25000;
+       unsigned step;
+       step = (max - min) / (MAX_SPEEDS - 1);
+       if (step < MIN_SPEED_STEP) step = MIN_SPEED_STEP;
+       pDebug(DBG_DIAG, "Speed step: %u kHz", step);
        /* Go to max speed if we are not already there  */
        for (unsigned current = getSpeed(); current < max; current += step)
                setSpeed(current);
_______________________________________________
powersave-devel mailing list
[email protected]
http://forge.novell.com/mailman/listinfo/powersave-devel

Reply via email to