summaryrefslogtreecommitdiffstats
path: root/cpufreq
blob: 28b40e9573457ee1574602ae9a76a08538e3da54 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash

RETVAL=0

start() {
	touch /var/lock/subsys/cpufreq
	test -f /etc/sysconfig/cpufreq && . /etc/sysconfig/cpufreq
	for cpu in /sys/devices/system/cpu/* ; do
		[ "x$GOVERNOR" != "x" ] && [ -f  $cpu/cpufreq/scaling_governor ] && echo $GOVERNOR > $cpu/cpufreq/scaling_governor
		[ "x$MAX_FREQ" != "x" ] && [ -f  $cpu/cpufreq/scaling_max_freq ] && echo $MAX_FREQ > $cpu/cpufreq/scaling_max_freq
		[ "x$MIN_FREQ" != "x" ] && [ -f  $cpu/cpufreq/scaling_min_freq ] && echo $MIN_FREQ > $cpu/cpufreq/scaling_min_freq
	done
}

stop() {
	# make sure no governor module is in use first
	# by switching to userspace governor (because it's built-in and won't modify frequency)
	for cpu in /sys/devices/system/cpu/* ; do
	    [ -f  $cpu/cpufreq/scaling_governor ] && echo userspace > $cpu/cpufreq/scaling_governor
	done
	rm -f /var/lock/subsys/cpufreq
}

reload() {
	stop
	start
}

case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	reload)
		reload
		;;
	*)
		echo "Usage: %s {start|stop|reload}" `basename $0`
		RETVAL=1
		;;
esac

exit $RETVAL