From 6dcbece026ff325bad87ad57c2c8420a9e45c963 Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Fri, 23 Mar 2001 11:15:46 +0000 Subject: (cleanup_subids): clean the unneeded/duplicated subids to keep pcitable clean (main source of dirtyness is modules.pcimap of the kernel) --- convert/merge2pcitable.pl | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'convert') 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"; + } + } +} -- cgit v1.2.1