--- cpufreqd-2.1.1-init.d 2006-07-04 18:34:49.000000000 +0200 +++ cpufreqd-init.d 2007-05-17 10:31:04.000000000 +0200 @@ -1,7 +1,7 @@ #!/sbin/runscript -# Copyright 1999-2006 Gentoo Foundation +# Copyright 1999-2007 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/sys-power/cpufreqd/files/cpufreqd-2.1.1-init.d,v 1.1 2006/07/04 16:34:49 brix Exp $ +# $Header: /var/cvsroot/gentoo-x86/sys-power/cpufreqd/files/cpufreqd-2.2.1-init.d,v 1.1 2006/11/30 16:42:10 peper Exp $ CONFIGFILE=/etc/cpufreqd.conf @@ -16,13 +16,29 @@ checkconfig() { return 1 fi - if [[ ! -e /proc/cpufreq ]] && [[ ! -e /sys/devices/system/cpu/cpu0/cpufreq ]]; then + if [[ ! -e /proc/cpufreq ]] ; then + for cpu in /sys/devices/system/cpu/cpu[0-9]* ; do + # We need just one cpu supporting freq scaling. + [[ -e ${cpu}/cpufreq ]] && return 0 + done eerror "cpufreqd requires the kernel to be configured with CONFIG_CPU_FREQ" + eerror "Make sure that the appropiate drivers for your CPU are available." return 1 fi } start() { + local module="" + + if [ -f /proc/modules ] ; then + einfo "Loading CPU Frequency scaling modules" + for module in ${MODULES} ; do + ebegin " Loading ${module}" + modprobe ${module} 2> /dev/null + eend $? + done + fi + checkconfig || return 1 ebegin "Starting CPU Frequency Daemon" @@ -32,7 +48,18 @@ start() { } stop() { + local module="" ebegin "Stopping CPU Frequency Daemon" start-stop-daemon --stop --exec /usr/sbin/cpufreqd eend ${?} + + if [ -f /proc/modules ] ; then + einfo "Unloading CPU Frequency scaling modules" + + for module in ${MODULES} ; do + ebegin " Unloading ${module}" + modprobe -r ${module} 2> /dev/null + eend $? + done + fi }