File rc.cpufreq of Package pm-utils.import5908
#!/bin/sh
# Author: Danny Kukawka <dkukawka@suse.de>
# Author: Vincent Untz <vuntz@opensuse.org>
#
# /etc/init.d/cpufreq
#
### BEGIN INIT INFO
# Provides: cpufreq
# Required-Start: $null
# Should-Start: $null
# Required-Stop: $null
# Should-Stop: $null
# Default-Start: 2 3 5
# Default-Stop:
# Short-Description: CPUFreq modules loader
# Description: This script loads the relevant CPUFreq modules in the kernel.
#
### END INIT INFO
# Parameters (startup)
CPUFREQ_SYSFS_PATH="/sys/devices/system/cpu/cpu0/cpufreq"
LOGGER="/bin/logger -t rc.cpufreq"
load_governors()
{
if [ ! -r $CPUFREQ_SYSFS_PATH ];then
$LOGGER Cannot load cpufreq governors - No cpufreq driver available
return 1
fi
read govs < $CPUFREQ_SYSFS_PATH/scaling_available_governors
case "$govs" in
*powersave*)
;;
*)
modprobe -q cpufreq_powersave >/dev/null 2>&1
[ $? != 0 ] && $LOGGER powersave cpufreq governor could not be loaded
;;
esac
case "$govs" in
*performance*)
;;
*)
modprobe -q cpufreq_performance >/dev/null 2>&1
[ $? != 0 ] && $LOGGER perfromance cpufreq governor could not be loaded
;;
esac
case "$govs" in
*userspace*)
;;
*)
modprobe -q cpufreq_userspace >/dev/null 2>&1
[ $? != 0 ] && $LOGGER userspace cpufreq governor could not be loaded
;;
esac
case "$govs" in
*ondemand*)
;;
*)
modprobe -q cpufreq_ondemand >/dev/null 2>&1
[ $? != 0 ] && $LOGGER ondemand cpufreq governor could not be loaded
;;
esac
case "$govs" in
*conservative*)
;;
*)
modprobe -q cpufreq_conservative >/dev/null 2>&1
[ $? != 0 ] && $LOGGER conservative cpufreq governor could not be loaded
;;
esac
return 0
}
function load_cpufreq_driver()
{
CPUFREQ_MODULES="acpi_cpufreq powernow_k8 powernow_k7 powernow_k6 longrun speedstep_ich"
CPUFREQ_MODULES_GREP="^acpi_cpufreq\|^speedstep_ich\|^powernow_k8\|^powernow_k7\|^powernow_k6\|^longrun\|^longhaul"
# if the drivers are compiled in, $CPUFREQ_SYSFS_PATH already exists
if [ ! -d $CPUFREQ_SYSFS_PATH ]; then
# test for already loaded modules
ALREADY_LOADED_MODS=`grep $CPUFREQ_MODULES_GREP /proc/modules`
if [ -z "$ALREADY_LOADED_MODS" ] ; then
for MODULE in $CPUFREQ_MODULES; do
modprobe $MODULE &>/dev/null
RETVAL=$?
[ "$RETVAL" = 0 ] && break
done
# skip if no module could be loaded!
if [ "$RETVAL" != 0 ]; then
$LOGGER "CPU frequency scaling is not supported by your processor."
$LOGGER "boot with 'CPUFREQ=no' in to avoid this warning."
# remove eventually loaded modules, bug 150381
rmmod speedstep_lib cpufreq_stats freq_table 2>/dev/null
return $RETVAL
fi
fi
fi
return 0
}
. /etc/rc.status
rc_reset
case "$1" in
start)
echo -n "Loading CPUFreq modules"
load_cpufreq_driver
if [ "$?" != 0 ]; then
echo -n " - hardware support not available"
rc_status -s
rc_exit
fi
load_governors
if [ "$?" != 0 ]; then
rc_failed 1
fi
rc_status -v
;;
stop)
rc_failed 0
rc_status
;;
try-restart|restart|reload|force-reload)
$0 start
;;
status)
echo -n "Checking CPUFreq modules"
if [ -r $CPUFREQ_SYSFS_PATH ]; then
rc_failed 0
else
rc_failed 3
fi
rc_status -v
;;
*)
echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload}"
exit 1
;;
esac
rc_exit