File: 94cpufreq

package info (click to toggle)
pm-utils 1.4.1-21
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,432 kB
  • sloc: sh: 3,069; xml: 1,035; makefile: 174; ansic: 152
file content (46 lines) | stat: -rwxr-xr-x 1,098 bytes parent folder | download | duplicates (8)
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
46
#!/bin/sh
# Ensure cpu governor is set to something sane.
# TODO: Which of the cpu governors is still insane?  File bugs against
#       those that are.

. "${PM_FUNCTIONS}"

[ -d /sys/devices/system/cpu/ ] || exit $NA

hibernate_cpufreq()
{
	( cd /sys/devices/system/cpu/
	for x in cpu[0-9]*; do
		# if cpufreq is a symlink, it is handled by another cpu. Skip.
		[ -L "$x/cpufreq" ] && continue
		gov="$x/cpufreq/scaling_governor"
		# if we do not have a scaling_governor file, skip.
		[ -f "$gov" ] || continue
		# if our temporary governor is not available, skip.
		grep -q "$TEMPORARY_CPUFREQ_GOVERNOR" \
			"$x/cpufreq/scaling_available_governors" || continue
		savestate "${x}_governor" < "$gov"
		echo "$TEMPORARY_CPUFREQ_GOVERNOR" > "$gov"
	done )
}

thaw_cpufreq()
{
	( cd /sys/devices/system/cpu/
	for x in cpu[0-9]*/cpufreq/scaling_governor ; do
		[ -f "$x" ] || continue
		state_exists "${x%%/*}_governor" || continue
		restorestate "${x%%/*}_governor" > "$x"
	done )
}

case "$1" in
	suspend|hibernate)
		hibernate_cpufreq
		;;
	resume|thaw)
		thaw_cpufreq
		;;
	*) exit $NA
		;;
esac