Use file globbing instead of trying to parse the output of ls, change
default governor from "userspace" to "performance" because performance
is the compiled-in default for just about everything that uses
cpufreq.
diff -U 0 -rNX diffignore pm-utils.updates/pm/sleep.d/94cpufreq working/pm/sleep.d/94cpufreq
--- pm-utils.updates/pm/sleep.d/94cpufreq	2008-01-27 11:58:02.000000000 -0600
+++ working/pm/sleep.d/94cpufreq	2008-01-26 13:56:11.000000000 -0600
@@ -7,18 +7,10 @@
-	[ -d /sys/devices/system/cpu/ ] || return 0
-	pushd /sys/devices/system/cpu/ >/dev/null 2>&1
-	for x in $(ls -1) ; do
-		[ -d $x/cpufreq ] || continue
-		[ -f $x/cpufreq/scaling_governor ] || continue
-
-		savestate ${x}_governor $(cat $x/cpufreq/scaling_governor)
-	done
-	for x in $(ls -1) ; do
-		[ -d $x/cpufreq ] || continue
-		[ -f $x/cpufreq/scaling_governor ] || continue
-
-		gov="$TEMPORARY_CPUFREQ_GOVERNOR"
-		grep -q "$GOVERNOR" $x/cpufreq/scaling_available_governors \
-			|| gov="userspace"
-		sh -c "echo \"$gov\" > $x/cpufreq/scaling_governor"
-	done
-	popd >/dev/null 2>&1
+	[ -d /sys/devices/system/cpu/ ] || return 1
+	( cd /sys/devices/system/cpu/
+	for x in cpu[0-9]* ; do
+		[ -f "$x/cpufreq/scaling_governor" ] || continue
+		savestate "${x}_governor" $(cat "$x/cpufreq/scaling_governor")
+		local gov="$TEMPORARY_CPUFREQ_GOVERNOR"
+		grep -q "$GOVERNOR" "$x/cpufreq/scaling_available_governors" \
+			|| gov="performance"
+		echo "$gov" > "$x/cpufreq/scaling_governor"
+	done )
@@ -29,3 +21,3 @@
-	x=0
-	while :; do
-		gov=$(restorestate $(echo cpu${x}_governor))
+	( cd /sys/devices/system/cpu/
+	for x in cpu[0-9]* ; do
+		local gov=$(restorestate "${x}_governor")
@@ -33,6 +25,2 @@
-
-		sh -c "echo \"$gov\" > /sys/devices/system/cpu/cpu$x/cpufreq/scaling_governor"
-		unset gov
-		x=$(($x + 1))
-	done
-	unset x
+		echo "$gov" > "$x/cpufreq/scaling_governor"
+	done )
_______________________________________________
Pm-utils mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/pm-utils

Reply via email to