summaryrefslogtreecommitdiffstats
path: root/mdk-stage1/pcmcia/merge_from_pcitable
blob: 16c72e8a53e2226f401bc9fb870e4eb6f09dd8a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/perl

# This program will show on stdout yenta_socket stuff from pcitable
# which is not in probe.c

use MDK::Common;

my %probes;
foreach (cat_('probe.c')) {
    if (/^pci_id_t pci_id\[\] = {/ ... /^};/) {
	/^\s*{\s*0x([\da-f]+),\s*0x([\da-f]+),\s*"([^"]*)",\s*"([^"]*)"\s*}/
	  and $probes{"$1$2"} = { vendor => $1, device => $2, driver => $3, name => $4 };
    }
}

require '/usr/bin/merge2pcitable.pl';
my $drivers = read_pcitable("/usr/share/ldetect-lst/pcitable");

my %pcitable = map_each {
    $::a =~ /^(....)(....)/ or die;
    "$1$2" => { vendor => $1, device => $2, driver => $::b->[0], name => $::b->[1] };
} %$drivers;

my @yenta_socket_ids = grep { $pcitable{$_}{driver} eq 'yenta_socket' } keys %pcitable;

if (my @missing_in_probe_c = difference2(\@yenta_socket_ids, [ keys %probes ])) {
    print "Missing in `probe.c':\n",
      map { 
	  my $p = $pcitable{$_};
	  qq(    { 0x$p->{vendor}, 0x$p->{device}, "yenta_socket", "$p->{name}" },\n);
      } sort @missing_in_probe_c;
}