diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2001-03-23 11:15:46 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2001-03-23 11:15:46 +0000 |
commit | 6dcbece026ff325bad87ad57c2c8420a9e45c963 (patch) | |
tree | 57d3a432dffebb0e6ef52200da09d1cdf318256d | |
parent | 6cc7d4bb9ffe73b67dce9ee152fc75381b355be5 (diff) | |
download | ldetect-lst-6dcbece026ff325bad87ad57c2c8420a9e45c963.tar ldetect-lst-6dcbece026ff325bad87ad57c2c8420a9e45c963.tar.gz ldetect-lst-6dcbece026ff325bad87ad57c2c8420a9e45c963.tar.bz2 ldetect-lst-6dcbece026ff325bad87ad57c2c8420a9e45c963.tar.xz ldetect-lst-6dcbece026ff325bad87ad57c2c8420a9e45c963.zip |
(cleanup_subids): clean the unneeded/duplicated subids to keep pcitable
clean (main source of dirtyness is modules.pcimap of the kernel)
-rwxr-xr-x | convert/merge2pcitable.pl | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/convert/merge2pcitable.pl b/convert/merge2pcitable.pl index f32cf4e3..b5fd394b 100755 --- a/convert/merge2pcitable.pl +++ b/convert/merge2pcitable.pl @@ -15,6 +15,7 @@ if ($0 =~ /merge2pcitable/) my $d_pci = read_pcitable($pcitable); my $d_in = $read->($in); merge($d_pci, $d_in); + cleanup_subids($d_pci); write_pcitable($d_pci); } else { 1 } @@ -171,3 +172,37 @@ sub merge { } } } + +sub cleanup_subids { + my ($drivers) = @_; + my %l, %m; + foreach (sort keys %$drivers) { + my ($id, $subid) = /(........)(........)/; + if ($l{$id}) { + push @{$m{$id}}, $l{$id}, $subid; + } else { + $l{$id} = $subid; + } + } + foreach my $id (keys %m) { + my %modules; + my $text; + foreach my $subid (@{$m{$id}}) { + my $e = $drivers->{"$id$subid"}; + $modules{$e->[0]} = 1; + $text = $e->[1] if length($e->[1]) > length($text); + } + if (keys(%modules) == 1) { + my ($module, undef) = %modules; + + # remove others + foreach my $subid (@{$m{$id}}) { + delete $drivers->{"$id$subid"}; + } + # add a main one + $drivers->{$id . 'ffffffff'} = [ $module, $text ]; + } else { +# print STDERR "keeping subids for $id ($text) because of ", join(", ", keys %modules), "\n"; + } + } +} |