From 319f9b8f681f4e0de852927658f2c9138df12788 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Wed, 16 Jan 2013 17:33:38 +0000 Subject: [PATCH] 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. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@6114 7894878c-1315-0410-8ee3-d5d059ff63e0 --- CHANGES | 1 + prog/detect/sensors-detect | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 70db5df4..b6698039 100644 --- a/CHANGES +++ b/CHANGES @@ -6,6 +6,7 @@ SVN HEAD sensors: Clarify what option -u is good for sensors-detect: Add detection of AMD family 16h power sensors Map IT8771E, IT8772E, IT8782F and IT8783F to it87 + Use /sys/module instead of /proc/modules where available 3.3.3 "Happy Birthday Sophie" (2012-11-06) documentation: Update fan-divisors, fan divisors are optional diff --git a/prog/detect/sensors-detect b/prog/detect/sensors-detect index cba73f99..fa13c5de 100755 --- a/prog/detect/sensors-detect +++ b/prog/detect/sensors-detect @@ -2773,9 +2773,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 () { - tr/-/_/; # Probably not needed $modules_list{$1} = 1 if m/^(\S*)/; } }