Submitted By:            Fernando de Oliveira <famobr at yahoo dot com dot br>
Date:                    2014-05-21
Initial Package Version: 3.3.5
Upstream Status:         Fixed
Origin:                  Upstream
URL:                     http://www.lm-sensors.org/changeset/6216
                         http://www.lm-sensors.org/changeset/6237
Description:             sensors.conf.default: Add support for NCT6779 and NCT6791
                         fancontrol: Deal with moving hwmon attributes

diff -Naur lm_sensors-3.3.5.orig/etc/sensors.conf.default lm_sensors-3.3.5/etc/sensors.conf.default
--- lm_sensors-3.3.5.orig/etc/sensors.conf.default	2012-01-31 11:25:29.057246000 -0300
+++ lm_sensors-3.3.5/etc/sensors.conf.default	2014-05-21 09:35:56.110779242 -0300
@@ -308,7 +308,7 @@
 #    set in8_max  3.0 * 1.10
 
 
-chip "w83627ehf-*" "w83627dhg-*" "w83667hg-*" "nct6775-*" "nct6776-*"
+chip "w83627ehf-*" "w83627dhg-*" "w83667hg-*" "nct6775-*" "nct6776-*" "nct6779-*" "nct6791-*"
 
     label in0 "Vcore"
     label in2 "AVCC"
diff -Naur lm_sensors-3.3.5.orig/prog/pwm/fancontrol lm_sensors-3.3.5/prog/pwm/fancontrol
--- lm_sensors-3.3.5.orig/prog/pwm/fancontrol	2013-05-23 11:09:22.043242000 -0300
+++ lm_sensors-3.3.5/prog/pwm/fancontrol	2014-05-21 09:35:56.109779277 -0300
@@ -206,6 +206,65 @@
 	return $outdated
 }
 
+function FixupDeviceFiles
+{
+	local DEVICE="$1"
+	local fcvcount pwmo tsen fan
+
+	let fcvcount=0
+	while (( $fcvcount < ${#AFCPWM[@]} )) # go through all pwm outputs
+	do
+		pwmo=${AFCPWM[$fcvcount]}
+		AFCPWM[$fcvcount]=${pwmo//$DEVICE\/device/$DEVICE}
+		if [ "${AFCPWM[$fcvcount]}" != "$pwmo" ]
+		then
+			echo "Adjusing $pwmo -> ${AFCPWM[$fcvcount]}"
+		fi
+		let fcvcount=$fcvcount+1
+	done
+
+	let fcvcount=0
+	while (( $fcvcount < ${#AFCTEMP[@]} )) # go through all temp inputs
+	do
+		tsen=${AFCTEMP[$fcvcount]}
+		AFCTEMP[$fcvcount]=${tsen//$DEVICE\/device/$DEVICE}
+		if [ "${AFCTEMP[$fcvcount]}" != "$tsen" ]
+		then
+			echo "Adjusing $tsen -> ${AFCTEMP[$fcvcount]}"
+		fi
+		let fcvcount=$fcvcount+1
+	done
+
+	let fcvcount=0
+	while (( $fcvcount < ${#AFCFAN[@]} )) # go through all fan inputs
+	do
+		fan=${AFCFAN[$fcvcount]}
+		AFCFAN[$fcvcount]=${fan//$DEVICE\/device/$DEVICE}
+		if [ "${AFCFAN[$fcvcount]}" != "$fan" ]
+		then
+			echo "Adjusing $fan -> ${AFCFAN[$fcvcount]}"
+		fi
+		let fcvcount=$fcvcount+1
+	done
+}
+
+# Some drivers moved their attributes from hard device to class device
+function FixupFiles
+{
+	local DEVPATH="$1"
+	local entry device
+
+	for entry in $DEVPATH
+	do
+		device=`echo "$entry" | sed -e 's/=[^=]*$//'`
+
+		if [ -e "$device/name" ]
+		then
+			FixupDeviceFiles "$device"
+		fi
+	done
+}
+
 # Check that all referenced sysfs files exist
 function CheckFiles
 {
@@ -306,6 +365,10 @@
 	echo "Configuration appears to be outdated, please run pwmconfig again" >&2
 	exit 1
 fi
+if [ "$DIR" = "/sys/class/hwmon" ]
+then
+	FixupFiles "$DEVPATH"
+fi
 CheckFiles || exit 1
 
 if [ -f "$PIDFILE" ]
