summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xv4l/scripts/make_makefile.pl36
-rwxr-xr-xv4l/scripts/rmmod.pl66
2 files changed, 32 insertions, 70 deletions
diff --git a/v4l/scripts/make_makefile.pl b/v4l/scripts/make_makefile.pl
index 709546fca..82821b43b 100755
--- a/v4l/scripts/make_makefile.pl
+++ b/v4l/scripts/make_makefile.pl
@@ -124,38 +124,27 @@ sub open_makefile($) {
close $in;
}
-my $obsolete;
+my %obsolete;
sub getobsolete()
{
- open OBSOLETE, "<obsolete.txt";
- while (<OBSOLETE>) {
- if (m/^\s*\#/) {
- next;
- }
- s/\s*\#.*$//;
- s/\n$//;
-
- my $idir=$_;
-
- if (!$idir) {
- next;
+ open OBSOLETE, '<obsolete.txt' or die "Can't open obsolete.txt: $!";
+ while (<OBSOLETE>) {
+ next if (/^\s*#/ || /^\s*$/);
+ chomp;
+ if (m|^(.*)/([^/]*)$|) {
+ $obsolete{$1}{"$2.ko"} = 1;
+ } else {
+ print "Unable to parse obsolete.txt:$.\n$_\n";
}
- my $file=$_;
-
- $idir=~ s|(^.*)/[^/]+|\1|;
- $file=~ s|^.*/||;
- $file.=".ko";
-
- $obsolete{$idir}{$file} = 1;
- }
+ }
- close OBSOLETE;
+ close OBSOLETE;
}
sub removeobsolete()
{
while ( my ($dir, $files) = each(%obsolete) ) {
- print OUT "\t\@echo -e \"\\nRemoving obsolete files at \$(KDIR26)/$dir:\"\n";
+ print OUT "\t\@echo -e \"\\nRemoving obsolete files from \$(KDIR26)/$dir:\"\n";
print OUT "\t\@files='", join(' ', keys %$files), "'; ";
print OUT "for i in \$\$files;do if [ -e \$(DESTDIR)\$(KDIR26)/$dir/\$\$i ]; then ";
@@ -219,6 +208,7 @@ while ( my ($dir, $files) = each(%instdir) ) {
# Print dependencies of Makefile.media
print OUT "Makefile.media: ../linux/drivers/media/Makefile \\\n";
+print OUT "\tobsolete.txt \\\n";
print OUT join(" \\\n", map("\t../linux/drivers/media/$_/Makefile", keys %instdir));
print OUT "\n";
close OUT;
diff --git a/v4l/scripts/rmmod.pl b/v4l/scripts/rmmod.pl
index 48bc7ac1f..ed79cbe1e 100755
--- a/v4l/scripts/rmmod.pl
+++ b/v4l/scripts/rmmod.pl
@@ -27,24 +27,18 @@ my %debug = ( "tuner" => "tuner_debug=1",
"dvb-usb-dibusb-common" => "debug=0x03",
);
-my @obsolete;
sub getobsolete()
{
- open OBSOLETE, "<obsolete.txt";
+ my @obsolete;
+ open OBSOLETE, '<obsolete.txt' or die "Unable to open obsolete.txt: $!";
while (<OBSOLETE>) {
- if (m/^\s*\#/) {
- next;
- }
- s/\s*\#.*$//;
- s/\n$//;
- s|^.*/||;
- if (!$_) {
- next;
- }
- push @obsolete,$_;
+ next if (/^\s*#/ || /^\s*$/);
+ chomp;
+ m|^.*/([^/]+)$| and push @obsolete, $1;
}
close OBSOLETE;
+ return @obsolete;
}
sub findprog($)
@@ -172,37 +166,18 @@ sub insmod ($)
}
}
-sub rmmod ()
-{
- getobsolete();
- my $rmmod = findprog('rmmod');
- while (my $key=pop @modlist) {
- my $dep=$key;
- $dep=~s/[\-]/_/g;
- if (exists ($loaded{$dep})) {
- print "$rmmod $dep\n";
- system "$rmmod $dep\n";
- }
- }
-}
-
-sub rm_obsolete ()
+sub rmmod(@)
{
- 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;
- }
+ my @not;
+ foreach (reverse @_) {
+ s/-/_/g;
+ if (exists ($loaded{$_})) {
+ print "$rmmod $_\n";
+ unshift @not, $_ if (system "$rmmod $_");
}
}
- @obsolete=@obsolete2;
+ return @not;
}
sub prepare_cmd()
@@ -223,18 +198,15 @@ if ($mode eq "load") {
if ($mode eq "unload") {
prepare_cmd;
parse_loaded;
- rmmod;
- if (length(@obsolete)) {
- rm_obsolete;
- rmmod;
- rm_obsolete;
+ my @notunloaded = rmmod(@modlist, getobsolete());
+ @notunloaded = rmmod(@notunloaded) if (@notunloaded);
+ if (@notunloaded) {
+ print "Couldn't unload: ", join(' ', @notunloaded), "\n";
}
} elsif ($mode eq "reload") {
prepare_cmd;
parse_loaded;
- my @modlist2=@modlist;
- rmmod;
- @modlist=@modlist2;
+ rmmod(@modlist);
insmod(0);
} elsif ($mode eq "debug") {
prepare_cmd;