mirror of
https://github.com/lm-sensors/lm-sensors.git
synced 2026-11-08 16:11:26 +00:00
Unload kernel drivers which we loaded ourselves when we are done with them.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@5433 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
1 parent
b3c97e6eb8
commit
9e482430e0
2 files changed
+34
-1
No files matched your search
@@ -25,6 +25,7 @@ SVN-HEAD
|
||||
Complete GL520SM detection
|
||||
Improve GL525SM detection a bit
|
||||
Let kernel 2.6.28 and later handle chips aliases
|
||||
Unload kernel drivers when we are done with them (#2329)
|
||||
|
||||
3.0.3 (2008-09-28)
|
||||
libsensors: Avoid namespace pollution
|
||||
|
||||
@@ -2290,7 +2290,7 @@ sub initialize_i2c_adapters_list
|
||||
# MODULES #
|
||||
###########
|
||||
|
||||
use vars qw(%modules_list %modules_supported);
|
||||
use vars qw(%modules_list %modules_supported @modules_we_loaded);
|
||||
|
||||
sub initialize_modules_list
|
||||
{
|
||||
@@ -2309,6 +2309,23 @@ sub initialize_modules_supported
|
||||
}
|
||||
}
|
||||
|
||||
sub unload_modules
|
||||
{
|
||||
return unless @modules_we_loaded;
|
||||
|
||||
# Attempt to unload all kernel drivers we loaded ourselves
|
||||
while (my $module = pop @modules_we_loaded) {
|
||||
print "Unloading $module... ";
|
||||
system("modprobe -r $module 2> /dev/null");
|
||||
if (($? >> 8) == 0) {
|
||||
print "OK\n";
|
||||
} else {
|
||||
print "failed\n";
|
||||
}
|
||||
}
|
||||
print "\n";
|
||||
}
|
||||
|
||||
#################
|
||||
# SYSFS HELPERS #
|
||||
#################
|
||||
@@ -5337,6 +5354,8 @@ sub main
|
||||
print "Loading failed... skipping.\n";
|
||||
} else {
|
||||
print "Module loaded successfully.\n";
|
||||
push @modules_we_loaded, $adapter;
|
||||
$modules_list{$adapter} = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5356,6 +5375,8 @@ sub main
|
||||
print "Loading failed, expect problems later on.\n";
|
||||
} else {
|
||||
print "Module loaded successfully.\n";
|
||||
push @modules_we_loaded, "i2c-dev";
|
||||
$modules_list{"i2c-dev"} = 1;
|
||||
}
|
||||
print "\n";
|
||||
}
|
||||
@@ -5589,6 +5610,17 @@ EOT
|
||||
"working properly. Monitoring programs won't work until the needed\n".
|
||||
"modules are loaded.\n\n";
|
||||
}
|
||||
|
||||
unload_modules();
|
||||
}
|
||||
|
||||
sub cleanup_on_int
|
||||
{
|
||||
print "\n";
|
||||
unload_modules();
|
||||
exit;
|
||||
}
|
||||
|
||||
$SIG{INT} = \&cleanup_on_int;
|
||||
|
||||
main;
|
||||
Reference in new issue
Block a user