File: //usr/lib/pm-utils/sleep.d/94cpufreq
#!/bin/bash
. /usr/lib/pm-utils/functions
hibernate_cpufreq()
{
[ -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
}
thaw_cpufreq()
{
x=0
while :; do
gov=$(restorestate $(echo cpu${x}_governor))
[ -z "$gov" ] && break
sh -c "echo \"$gov\" > /sys/devices/system/cpu/cpu$x/cpufreq/scaling_governor"
unset gov
x=$(($x + 1))
done
unset x
}
case "$1" in
suspend|hibernate)
hibernate_cpufreq
;;
resume|thaw)
thaw_cpufreq
;;
*)
;;
esac
exit $?