aboutsummaryrefslogtreecommitdiff
fancontrol: Deal with moving hwmon attributes

Several kernel drivers have already moved their attributes from the
hardware device to the hwmon class device, and others will follow.
Teach fancontrol about this possibility and let it adjust the attribute
paths transparently.

Patch by Jean Delvare <khali@linux-fr.org>.
See <http://www.lm-sensors.org/changeset/6216>.

--- lm-sensors/prog/pwm/fancontrol	(revision 6172)
+++ lm-sensors/prog/pwm/fancontrol	(revision 6216)
@@ -207,4 +207,63 @@
 }
 
+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,4 +365,8 @@
 	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
'>libelf provides libelf.so.0, elfutils libelf.so.1. rmlint links only to one. * gnu/packages/disk.scm (rmlint)[inputs]: Remove libelf. Tobias Geerinckx-Rice 2023-08-06gnu: rmlint: Update package style....* gnu/packages/disk.scm (rmlint)[arguments]: Rewrite as G-expressions. [native-inputs, inputs]: Remove input labels. Tobias Geerinckx-Rice 2023-08-06gnu: rmlint: Update to 2.10.2....* gnu/packages/disk.scm (rmlint): Update to 2.10.2. Tobias Geerinckx-Rice 2023-07-30gnu: ndctl: Update to 78....* gnu/packages/disk.scm (ndctl): Update to 78. [inputs]: Add libtraceevent & libtracefs. Tobias Geerinckx-Rice 2023-07-23gnu: parted: Update to 3.6....* gnu/packages/disk.scm (parted): Update to 3.6. Tobias Geerinckx-Rice 2023-07-21gnu: parted: Skip tests when cross-compiling....* gnu/packages/disk.scm (parted)[arguments]: Adjust #:tests? to skip tests when cross-compiling. Efraim Flashner 2023-07-20gnu: parted: Disable tests for the Hurd....* gnu/packages/disk.scm (parted)[argument]: Set #:tests? to #false when building for the Hurd. Janneke Nieuwenhuizen