From a25e48640b4d11cdb4d83cb878af082a00df59b9 Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Thu, 13 Sep 2001 13:41:11 +0000 Subject: use the sub-category for usb probing --- generate_pciclass.pl | 2 +- generate_usbclass.pl | 11 +++++++---- ldetect.spec | 5 ++++- libldetect.h | 6 +++--- usb.c | 7 +++---- 5 files changed, 18 insertions(+), 13 deletions(-) diff --git a/generate_pciclass.pl b/generate_pciclass.pl index c879615..e6ed87a 100644 --- a/generate_pciclass.pl +++ b/generate_pciclass.pl @@ -15,7 +15,7 @@ print ' int nb_pciclasses = sizeof(pciclasses) / sizeof(*pciclasses); -extern const char *pci_class2text(unsigned short class) { +extern const char *pci_class2text(unsigned long class) { int i; for (i = 0; i < nb_pciclasses; i++) if (pciclasses[i].id == class) return pciclasses[i].name; diff --git a/generate_usbclass.pl b/generate_usbclass.pl index 63206c8..50fe13b 100755 --- a/generate_usbclass.pl +++ b/generate_usbclass.pl @@ -3,7 +3,7 @@ print q(/* This auto-generated from , don't modify! */ struct { - unsigned short id; + unsigned long id; const char *name; } usbclasses[] = { ); @@ -11,9 +11,12 @@ struct { while (<>) { chomp; if (/^C\s+(\d+)\s+(.*)/) { - ($cat, $descr) = ($1, $2); + ($cat, $cat_descr) = ($1, $2); + } elsif (/^\t(\d+)\s+(.*)/ && defined $cat) { + ($sub, $sub_descr) = ($1, $2); + $sub =~ /^\d\d$/ or die "bad line $.: sub category number badly formatted ($_)\n"; } elsif (/^\t\t(\d+)\s+(.*)/ && defined $cat) { - print qq(/* $. */ { 0x$cat$1, "$descr|$2" },\n); + print qq(/* $. */ { 0x$cat$sub$1, "$cat_descr|$sub_descr|$2" },\n); } elsif (/^\S/) { undef $cat; } @@ -24,7 +27,7 @@ print ' int nb_usbclasses = sizeof(usbclasses) / sizeof(*usbclasses); -extern const char *usb_class2text(unsigned short class) { +extern const char *usb_class2text(unsigned long class) { int i; for (i = 0; i < nb_usbclasses; i++) if (usbclasses[i].id == class) return usbclasses[i].name; diff --git a/ldetect.spec b/ldetect.spec index fc2feee..817f2b5 100644 --- a/ldetect.spec +++ b/ldetect.spec @@ -1,7 +1,7 @@ # !! DON'T MODIFY HERE, MODIFY IN THE CVS !! %define name ldetect %define version 0.2.4 -%define release 1mdk +%define release 2mdk Name: %{name} Version: %{version} @@ -53,6 +53,9 @@ rm -rf $RPM_BUILD_ROOT %{_libdir}/* %changelog +* Thu Sep 13 2001 Pixel 0.2.4-2mdk +- use the sub-category for usb probing + * Tue Sep 11 2001 Guillaume Cottenceau 0.2.4-1mdk - add "-v" and "-f" options to lspcidrake for (v)erbose mode and (f)ull probe diff --git a/libldetect.h b/libldetect.h index d61b0ab..4733d9e 100644 --- a/libldetect.h +++ b/libldetect.h @@ -7,7 +7,7 @@ struct pciusb_entry { unsigned short subvendor; /* 0xffff if not probe_type'd or no subid */ unsigned short subdevice; /* 0xffff if not probe_type'd or no subid */ - unsigned short class; /* 0 if not probe_type'd */ + unsigned long class; /* 0 if not probe_type'd */ unsigned short pci_bus; /* pci bus id 8 bits wide */ unsigned short pci_device; /* pci device id 5 bits wide */ @@ -28,10 +28,10 @@ extern void pciusb_free(struct pciusb_entries entries); /* pci ************************************************************************/ /******************************************************************************/ extern struct pciusb_entries pci_probe(int probe_type); /* probe_type is boolean */ -extern const char *pci_class2text(unsigned short class); +extern const char *pci_class2text(unsigned long class); /******************************************************************************/ /* usb ************************************************************************/ /******************************************************************************/ extern struct pciusb_entries usb_probe(void); -extern const char *usb_class2text(unsigned short class); +extern const char *usb_class2text(unsigned long class); diff --git a/usb.c b/usb.c index d1fab02..84b54d5 100644 --- a/usb.c +++ b/usb.c @@ -30,10 +30,9 @@ extern struct pciusb_entries usb_probe(void) { pciusb_initialize(e); } } else if (e && buf[0] == 'I' && e->class == 0) { - int class, prot = 0; - if (sscanf(buf, "I: If#=%*2d Alt=%*2d #EPs=%*2d Cls=%02x(%*5c) Sub=%*02x Prot=%02x", &class, &prot) == 2) { - /* we fake a class based on class and proto, subclass unneeded? */ - e->class = class * 0x100 + prot; + int class, sub, prot = 0; + if (sscanf(buf, "I: If#=%*2d Alt=%*2d #EPs=%*2d Cls=%02x(%*5c) Sub=%02x Prot=%02x", &class, &sub, &prot) == 3) { + e->class = (class * 0x100 + sub) * 0x100 + prot; } else { fprintf(stderr, "%s %d: unknown ``I'' line\n", file, line); } -- cgit v1.2.1