[PATCH] sensors-detect: Use /sys/module where available

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If a driver is built into the kernel, it doesn't show up in
/proc/modules so we will try to load it, even though it's already
available. It will succeed, however later attempts to remove the
driver will fail and such failures are reported at the end of the
script, which can be confusing.

So, use /sys/module instead of /proc/modules where available, as
built-in drivers are listed there too so we no longer attempt to load
already available drivers. As a consequence we also no longer attempt
to remove the drivers in question, thus clearing the error message.
---
 prog/detect/sensors-detect |   12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

--- lm-sensors.orig/prog/detect/sensors-detect	2012-11-10 11:20:42.000000000 +0100
+++ lm-sensors/prog/detect/sensors-detect	2012-11-10 14:32:12.546135606 +0100
@@ -2765,9 +2765,19 @@ sub initialize_modules_list
 {
 	local $_;
 
+	# /sys/module contains built-in drivers too, but doesn't exist on
+	# older kernels (added in kernel 2.6.7)
+	if (opendir(local *MODULES, "$sysfs_root/module")) {
+		while (defined($_ = readdir(MODULES))) {
+			next if m/^\./;
+			$modules_list{$1} = 1 if m/^(\S*)/;
+		}
+		return;
+	}
+
+	# Fall back to /proc/modules as it is always available
 	open(local *INPUTFILE, "/proc/modules") or return;
 	while (<INPUTFILE>) {
-		tr/-/_/; # Probably not needed
 		$modules_list{$1} = 1 if m/^(\S*)/;
 	}
 }

-- 
Jean Delvare

_______________________________________________
lm-sensors mailing list
lm-sensors@xxxxxxxxxxxxxx
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors


[Index of Archives]     [Linux Kernel]     [Linux Hardware Monitoring]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux