summaryrefslogtreecommitdiff
path: root/v4l/scripts/rmmod.pl
diff options
context:
space:
mode:
Diffstat (limited to 'v4l/scripts/rmmod.pl')
-rwxr-xr-xv4l/scripts/rmmod.pl44
1 files changed, 44 insertions, 0 deletions
diff --git a/v4l/scripts/rmmod.pl b/v4l/scripts/rmmod.pl
index d190a9edf..48bc7ac1f 100755
--- a/v4l/scripts/rmmod.pl
+++ b/v4l/scripts/rmmod.pl
@@ -27,6 +27,25 @@ my %debug = ( "tuner" => "tuner_debug=1",
"dvb-usb-dibusb-common" => "debug=0x03",
);
+my @obsolete;
+sub getobsolete()
+{
+ open OBSOLETE, "<obsolete.txt";
+ while (<OBSOLETE>) {
+ if (m/^\s*\#/) {
+ next;
+ }
+ s/\s*\#.*$//;
+ s/\n$//;
+ s|^.*/||;
+ if (!$_) {
+ next;
+ }
+ push @obsolete,$_;
+ }
+
+ close OBSOLETE;
+}
sub findprog($)
{
@@ -155,6 +174,7 @@ sub insmod ($)
sub rmmod ()
{
+ getobsolete();
my $rmmod = findprog('rmmod');
while (my $key=pop @modlist) {
my $dep=$key;
@@ -166,6 +186,25 @@ sub rmmod ()
}
}
+sub rm_obsolete ()
+{
+ getobsolete();
+ my @obsolete2;
+
+ my $rmmod = findprog('rmmod');
+ while (my $key=pop @obsolete) {
+ my $dep=$key;
+ $dep=~s/[\-]/_/g;
+ if (exists ($loaded{$dep})) {
+ print "$rmmod $dep\n";
+ if (system "$rmmod $dep\n") {
+ push @obsolete2,$key;
+ }
+ }
+ }
+ @obsolete=@obsolete2;
+}
+
sub prepare_cmd()
{
find(\&parse_dir, ".");
@@ -185,6 +224,11 @@ if ($mode eq "load") {
prepare_cmd;
parse_loaded;
rmmod;
+ if (length(@obsolete)) {
+ rm_obsolete;
+ rmmod;
+ rm_obsolete;
+ }
} elsif ($mode eq "reload") {
prepare_cmd;
parse_loaded;