summarylogtreecommitdiffstats
path: root/fancontrol-max-of-fctemps.patch
blob: 4c098edc8dd38a9e8952b18a84abc155094dcf8a (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
Chusslove Illich (Часлав Илић)
Index: doc/fancontrol.txt
===================================================================
--- doc/fancontrol.txt	(revision 6037)
+++ doc/fancontrol.txt	(working copy)
@@ -37,6 +37,10 @@
 	Maps pwm outputs to temperature sensors so fancontrol knows which
 	temperature sensors should be used for calculation of new values for
 	the corresponding pwm outputs.
+	Several temperature sensors may be mapped to single pwm output
+	as a comma-separated list, in which case the maximum of all readings
+	is taken as the referent temperature. This is useful for a CPU fan
+	on a multi-core CPU with separate temperature sensors per core.
 
 FCFANS
 	FCFANS records the association between a pwm and a fan.
Index: prog/pwm/fancontrol
===================================================================
--- prog/pwm/fancontrol	(revision 6037)
+++ prog/pwm/fancontrol	(working copy)
@@ -224,12 +224,14 @@
 	let fcvcount=0
 	while (( $fcvcount < ${#AFCTEMP[@]} )) # go through all temp inputs
 	do
-		tsen=${AFCTEMP[$fcvcount]}
-		if [ ! -r $tsen ]
-		then
-			echo "Error: file $tsen doesn't exist" >&2
-			outdated=1
-		fi
+		for tsen in $(echo ${AFCTEMP[$fcvcount]} | tr ',' ' ')
+		do
+			if [ ! -r $tsen ]
+			then
+				echo "Error: file $tsen doesn't exist" >&2
+				outdated=1
+			fi
+		done
 		let fcvcount=$fcvcount+1
 	done
 
@@ -391,12 +393,20 @@
 		minpwm=${AFCMINPWM[$fcvcount]}
 		maxpwm=${AFCMAXPWM[$fcvcount]}
 
-		read tval < ${tsens}
-		if [ $? -ne 0 ]
-		then
-			echo "Error reading temperature from $DIR/$tsens"
-			restorefans 1
-		fi
+		tval=0
+		for tsen in $(echo ${tsens} | tr ',' ' ')
+		do
+			read tval1 < ${tsen}
+			if [ $? -ne 0 ]
+			then
+				echo "Error reading temperature from $DIR/$tsen"
+				restorefans 1
+			fi
+			if [ $tval -lt $tval1 ]
+			then
+				tval=$tval1
+			fi
+		done
 
 		read pwmpval < ${pwmo}
 		if [ $? -ne 0 ]