From 0947edecbffaf9bfc05873e6af849b62b0cb3e0b Mon Sep 17 00:00:00 2001 From: Jiri Moskovcak Date: Mon, 30 Aug 2010 13:33:50 +0200 Subject: [PATCH] removed unused patches --- usbutils-0.11-endian.patch | 60 ----- usbutils-0.11-hidcc.patch | 86 ------ usbutils-0.70-hwdata.patch | 21 -- usbutils-0.71-VT.patch | 95 ------- usbutils-0.73-hwdata.patch | 21 -- usbutils-0.82-hwdata.patch | 59 ---- usbutils-0.9-hwdata.patch | 59 ---- usbutils-0214.patch | 537 ------------------------------------- 8 files changed, 938 deletions(-) delete mode 100644 usbutils-0.11-endian.patch delete mode 100644 usbutils-0.11-hidcc.patch delete mode 100644 usbutils-0.70-hwdata.patch delete mode 100644 usbutils-0.71-VT.patch delete mode 100644 usbutils-0.73-hwdata.patch delete mode 100644 usbutils-0.82-hwdata.patch delete mode 100644 usbutils-0.9-hwdata.patch delete mode 100644 usbutils-0214.patch diff --git a/usbutils-0.11-endian.patch b/usbutils-0.11-endian.patch deleted file mode 100644 index 8358a42..0000000 --- a/usbutils-0.11-endian.patch +++ /dev/null @@ -1,60 +0,0 @@ ---- usbutils-0.11/lsusb.c.endian 2005-01-20 08:14:23.234480568 +0000 -+++ usbutils-0.11/lsusb.c 2005-01-20 08:14:34.742731048 +0000 -@@ -35,6 +35,13 @@ - #include - #include - #include -+#include -+ -+#if __BYTE_ORDER == __BIG_ENDIAN -+#define BE 1 -+#else -+#define BE 0 -+#endif - - #include - #ifdef HAVE_LINUX_USBDEVICE_FS_H -@@ -290,8 +297,8 @@ static void dump_device(int fd, unsigned - printf(" Warning: Invalid descriptor\n"); - else if (buf[0] < 18) - printf(" Warning: Descriptor too short\n"); -- vid = buf[8] | (buf[9] << 8); -- pid = buf[10] | (buf[11] << 8); -+ vid = *(u_int16_t *)(buf+8); -+ pid = *(u_int16_t *)(buf+10); - get_vendor_string(vendor, sizeof(vendor), vid); - get_product_string(product, sizeof(product), vid, pid); - get_class_string(cls, sizeof(cls), buf[4]); -@@ -315,8 +322,8 @@ static void dump_device(int fd, unsigned - " iProduct %5u %s\n" - " iSerial %5u %s\n" - " bNumConfigurations %5u\n", -- buf[0], buf[1], buf[3], buf[2], buf[4], cls, buf[5], subcls, buf[6], proto, buf[7], -- vid, vendor, pid, product, buf[13], buf[12], buf[14], mfg, buf[15], prod, buf[16], serial, buf[17]); -+ buf[0], buf[1], buf[3-BE], buf[2+BE], buf[4], cls, buf[5], subcls, buf[6], proto, buf[7], -+ vid, vendor, pid, product, buf[13-BE], buf[12+BE], buf[14], mfg, buf[15], prod, buf[16], serial, buf[17]); - dump_junk(buf, " ", 18); - } - -@@ -1575,8 +1582,8 @@ static int dump_one_device(const char *p - fprintf(stderr, "cannot get config descriptor, %s (%d)\n", strerror(errno), errno); - goto err; - } -- vid = buf[8] | (buf[9] << 8); -- pid = buf[10] | (buf[11] << 8); -+ vid = *(u_int16_t *)(buf+8); -+ pid = *(u_int16_t *)(buf+10); - get_vendor_string(vendor, sizeof(vendor), vid); - get_product_string(product, sizeof(product), vid, pid); - printf("Device: ID %04x:%04x %s %s\n", vid, pid, vendor, product); -@@ -1628,8 +1635,8 @@ static int list_devices(int bus, int dev - fprintf(stderr, "cannot read device descriptor %s (%d)\n", strerror(errno), errno); - goto err; - } -- vid = buf[8] | (buf[9] << 8); -- pid = buf[10] | (buf[11] << 8); -+ vid = *(u_int16_t *)(buf+8); -+ pid = *(u_int16_t *)(buf+10); - if (buf[0] >= USB_DT_DEVICE_SIZE && ((vendorid != -1 && vendorid != vid) || (productid != -1 && productid != pid))) - goto err; - status=0; diff --git a/usbutils-0.11-hidcc.patch b/usbutils-0.11-hidcc.patch deleted file mode 100644 index 55c7d0d..0000000 --- a/usbutils-0.11-hidcc.patch +++ /dev/null @@ -1,86 +0,0 @@ ---- usbutils-0.11/names.c.hidcc 2002-06-17 11:13:47.000000000 +0200 -+++ usbutils-0.11/names.c 2004-09-01 10:53:12.716443518 +0200 -@@ -116,6 +116,7 @@ - static struct genericstrtable *physdess[HASHSZ] = { NULL, }; - static struct genericstrtable *hutus[HASHSZ] = { NULL, }; - static struct genericstrtable *langids[HASHSZ] = { NULL, }; -+static struct genericstrtable *countrycodes[HASHSZ] = { NULL, }; - - /* ---------------------------------------------------------------------- */ - -@@ -164,6 +165,11 @@ - return names_genericstrtable(biass, b); - } - -+const char *names_countrycode(unsigned int countrycode) -+{ -+ return names_genericstrtable(countrycodes, countrycode); -+} -+ - const char *names_vendor(u_int16_t vendorid) - { - struct vendor *v; -@@ -402,6 +408,11 @@ - return new_genericstrtable(biass, name, b); - } - -+static int new_countrycode(const char *name, unsigned int countrycode) -+{ -+ return new_genericstrtable(countrycodes, name, countrycode); -+} -+ - /* ---------------------------------------------------------------------- */ - - #define DBG(x) -@@ -553,6 +564,27 @@ - DBG(printf("line %5u audio terminal type %02x %s\n", linectr, u, cp)); - continue; - } -+ if (buf[0] == 'H' && buf[1] == 'C' && buf[2] == 'C' && isspace(buf[3])) { -+ /* HID Descriptor bCountryCode */ -+ cp = buf+3; -+ while (isspace(*cp)) -+ cp++; -+ if (!isxdigit(*cp)) { -+ fprintf(stderr, "Invalid HID country code at line %u\n", linectr); -+ continue; -+ } -+ u = strtoul(cp, &cp, 10); -+ while (isspace(*cp)) -+ cp++; -+ if (!*cp) { -+ fprintf(stderr, "Invalid HID country code at line %u\n", linectr); -+ continue; -+ } -+ if (new_countrycode(cp, u)) -+ fprintf(stderr, "Duplicate HID country code at line %u country %02u %s\n", linectr, u, cp); -+ DBG(printf("line %5u keyboard country code %02u %s\n", linectr, u, cp)); -+ continue; -+ } - if (isxdigit(*cp)) { - /* vendor */ - u = strtoul(cp, &cp, 16); ---- usbutils-0.11/names.h.hidcc 2000-11-06 16:00:06.000000000 +0100 -+++ usbutils-0.11/names.h 2004-09-01 10:53:14.097253193 +0200 -@@ -44,6 +44,7 @@ - extern const char *names_langid(u_int16_t langid); - extern const char *names_physdes(u_int8_t ph); - extern const char *names_bias(u_int8_t b); -+extern const char *names_countrycode(unsigned int countrycode); - extern int names_init(char *n); - - /* ---------------------------------------------------------------------- */ ---- usbutils-0.11/lsusb.c.hidcc 2004-08-30 17:57:04.000000000 +0200 -+++ usbutils-0.11/lsusb.c 2004-09-01 11:03:48.208861173 +0200 -@@ -1205,9 +1205,9 @@ - " bLength %5u\n" - " bDescriptorType %5u\n" - " bcdHID %2x.%02x\n" -- " bCountryCode %5u\n" -+ " bCountryCode %5u %s\n" - " bNumDescriptors %5u\n", -- buf[0], buf[1], buf[3], buf[2], buf[4], buf[5]); -+ buf[0], buf[1], buf[3], buf[2], buf[4], names_countrycode(buf[4]) ? : "Unknown", buf[5]); - for (i = 0; i < buf[5]; i++) - printf(" bDescriptorType %5u %s\n" - " wDescriptorLength %5u\n", diff --git a/usbutils-0.70-hwdata.patch b/usbutils-0.70-hwdata.patch deleted file mode 100644 index fb97525..0000000 --- a/usbutils-0.70-hwdata.patch +++ /dev/null @@ -1,21 +0,0 @@ ---- usbutils-0.70/Makefile.in.hwdata 2005-04-14 18:12:45.000000000 +0200 -+++ usbutils-0.70/Makefile.in 2005-04-14 18:12:59.000000000 +0200 -@@ -180,7 +180,7 @@ - sharedstatedir = @sharedstatedir@ - sysconfdir = @sysconfdir@ - target_alias = @target_alias@ --AM_CPPFLAGS = -DUSBIDS_FILE='"@datadir@/usb.ids"' -+AM_CPPFLAGS = -DUSBIDS_FILE='"@datadir@/hwdata/usb.ids"' - AM_CFLAGS = -Wall -W -Wunused - lsusb_SOURCES = lsusb.c \ - names.c names.h \ ---- usbutils-0.70/Makefile.am.hwdata 2005-04-14 18:12:22.000000000 +0200 -+++ usbutils-0.70/Makefile.am 2005-04-14 18:13:14.000000000 +0200 -@@ -1,6 +1,6 @@ - # Process this file with 'automake' to create 'Makefile.in' - --AM_CPPFLAGS = -DUSBIDS_FILE='"@datadir@/usb.ids"' -+AM_CPPFLAGS = -DUSBIDS_FILE='"@datadir@/hwdata/usb.ids"' - - AM_CFLAGS = -Wall -W -Wunused - diff --git a/usbutils-0.71-VT.patch b/usbutils-0.71-VT.patch deleted file mode 100644 index ff3cfe5..0000000 --- a/usbutils-0.71-VT.patch +++ /dev/null @@ -1,95 +0,0 @@ ---- usbutils-0.71/names.c 2005-01-23 00:03:47.000000000 +0100 -+++ usbutils-0.72/names.c 2005-10-22 07:59:50.000000000 +0200 -@@ -79,6 +79,12 @@ - char name[1]; - }; - -+struct videoterminal { -+ struct videoterminal *next; -+ u_int16_t termt; -+ char name[1]; -+}; -+ - struct genericstrtable { - struct genericstrtable *next; - unsigned int num; -@@ -109,6 +115,7 @@ - static struct subclass *subclasses[HASHSZ] = { NULL, }; - static struct protocol *protocols[HASHSZ] = { NULL, }; - static struct audioterminal *audioterminals[HASHSZ] = { NULL, }; -+static struct videoterminal *videoterminals[HASHSZ] = { NULL, }; - static struct genericstrtable *hiddescriptors[HASHSZ] = { NULL, }; - static struct genericstrtable *reports[HASHSZ] = { NULL, }; - static struct genericstrtable *huts[HASHSZ] = { NULL, }; -@@ -236,6 +243,17 @@ - return NULL; - } - -+const char *names_videoterminal(u_int16_t termt) -+{ -+ struct videoterminal *vt; -+ -+ vt = videoterminals[hashnum(termt)]; -+ for (; vt; vt = vt->next) -+ if (vt->termt == termt) -+ return vt->name; -+ return NULL; -+} -+ - /* ---------------------------------------------------------------------- */ - - static int new_vendor(const char *name, u_int16_t vendorid) -@@ -356,6 +374,25 @@ - return 0; - } - -+static int new_videoterminal(const char *name, u_int16_t termt) -+{ -+ struct videoterminal *vt; -+ unsigned int h = hashnum(termt); -+ -+ vt = videoterminals[h]; -+ for (; vt; vt = vt->next) -+ if (vt->termt == termt) -+ return -1; -+ vt = malloc(sizeof(struct videoterminal) + strlen(name)); -+ if (!vt) -+ return -1; -+ strcpy(vt->name, name); -+ vt->termt = termt; -+ vt->next = videoterminals[h]; -+ videoterminals[h] = vt; -+ return 0; -+} -+ - static int new_genericstrtable(struct genericstrtable *t[HASHSZ], const char *name, unsigned int index) - { - struct genericstrtable *g; -@@ -564,6 +601,27 @@ - DBG(printf("line %5u audio terminal type %02x %s\n", linectr, u, cp)); - continue; - } -+ if (buf[0] == 'V' && buf[1] == 'T' && isspace(buf[2])) { -+ /* video terminal type spec */ -+ cp = buf+3; -+ while (isspace(*cp)) -+ cp++; -+ if (!isxdigit(*cp)) { -+ fprintf(stderr, "Invalid video terminal type at line %u\n", linectr); -+ continue; -+ } -+ u = strtoul(cp, &cp, 16); -+ while (isspace(*cp)) -+ cp++; -+ if (!*cp) { -+ fprintf(stderr, "Invalid video terminal type at line %u\n", linectr); -+ continue; -+ } -+ if (new_videoterminal(cp, u)) -+ fprintf(stderr, "Duplicate video terminal type spec at line %u terminal type %04x %s\n", linectr, u, cp); -+ DBG(printf("line %5u video terminal type %02x %s\n", linectr, u, cp)); -+ continue; -+ } - if (buf[0] == 'H' && buf[1] == 'C' && buf[2] == 'C' && isspace(buf[3])) { - /* HID Descriptor bCountryCode */ - cp = buf+3; diff --git a/usbutils-0.73-hwdata.patch b/usbutils-0.73-hwdata.patch deleted file mode 100644 index 56a8110..0000000 --- a/usbutils-0.73-hwdata.patch +++ /dev/null @@ -1,21 +0,0 @@ ---- usbutils-0.73/Makefile.am_old 2008-01-17 16:28:55.000000000 +0100 -+++ usbutils-0.73/Makefile.am 2008-01-17 16:29:08.000000000 +0100 -@@ -1,6 +1,6 @@ - # Process this file with 'automake' to create 'Makefile.in' - --AM_CPPFLAGS = -DUSBIDS_DIR='"@datadir@"' -+AM_CPPFLAGS = -DUSBIDS_DIR='"@datadir@/hwdata"' - - AM_CFLAGS = -Wall -W -Wunused - ---- usbutils-0.73/Makefile.in_old 2008-01-17 16:36:28.000000000 +0100 -+++ usbutils-0.73/Makefile.in 2008-01-17 16:35:38.000000000 +0100 -@@ -163,7 +163,7 @@ sbindir = @sbindir@ - sharedstatedir = @sharedstatedir@ - sysconfdir = @sysconfdir@ - target_alias = @target_alias@ --AM_CPPFLAGS = -DUSBIDS_DIR='"@datadir@"' -+AM_CPPFLAGS = -DUSBIDS_DIR='"@datadir@/hwdata"' - AM_CFLAGS = -Wall -W -Wunused - lsusb_SOURCES = lsusb.c \ - names.c names.h \ diff --git a/usbutils-0.82-hwdata.patch b/usbutils-0.82-hwdata.patch deleted file mode 100644 index 6000f4d..0000000 --- a/usbutils-0.82-hwdata.patch +++ /dev/null @@ -1,59 +0,0 @@ ---- usbutils-0.82/Makefile.am 2009-05-07 00:05:10.000000000 +0200 -+++ usbutils-0.82_hwdata/Makefile.am 2009-07-01 13:05:11.000000000 +0200 -@@ -1,18 +1,9 @@ - AM_LDFLAGS = \ - -Wl,--as-needed - --data_DATA = \ -- usb.ids --if HAVE_ZLIB --data_DATA += usb.ids.gz --endif -- - sbin_PROGRAMS = \ - lsusb - --sbin_SCRIPTS = \ -- update-usbids.sh -- - lsusb_SOURCES = \ - lsusb.c \ - lsusb-t.c \ -@@ -23,7 +14,7 @@ lsusb_SOURCES = \ - - lsusb_CPPFLAGS = \ - $(AM_CPPFLAGS) \ -- -DDATADIR=\"$(datadir)\" -+ -DDATADIR=\"$(datadir)/hwdata\" - - lsusb_LDADD = \ - $(LIBUSB_LIBS) -@@ -32,18 +23,9 @@ man_MANS = \ - lsusb.8 - - EXTRA_DIST = \ -- usb.ids \ -- update-usbids.sh.in \ - lsusb.8.in \ - usbutils.pc.in - --usb.ids.gz: $(srcdir)/usb.ids -- gzip -c -9 $< > $@ -- --update-usbids.sh: $(srcdir)/update-usbids.sh.in -- sed 's|@usbids@|$(datadir)/usb.ids|g' $< >$@ -- chmod 755 $@ -- - lsusb.8: $(srcdir)/lsusb.8.in - sed 's|@usbids@|$(datadir)/usb.ids|g' $< >$@ - -@@ -54,9 +36,7 @@ usbutils.pc: $(srcdir)/usbutils.pc.in - sed 's|@usbids@|$(datadir)/usb.ids|g;s|@VERSION[@]|$(VERSION)|g' $< >$@ - - DISTCLEANFILES = \ -- usb.ids.gz \ - lsusb.8 \ -- update-usbids.sh \ - usbutils.pc - - distclean-local: diff --git a/usbutils-0.9-hwdata.patch b/usbutils-0.9-hwdata.patch deleted file mode 100644 index 7aa84a8..0000000 --- a/usbutils-0.9-hwdata.patch +++ /dev/null @@ -1,59 +0,0 @@ ---- usbutils-0.9/configure.hwdata Wed Jan 30 19:45:49 2002 -+++ usbutils-0.9/configure Wed Jan 30 19:46:15 2002 -@@ -1761,18 +1761,18 @@ - if test "x${datadir}" = 'x${prefix}/share'; then - if test "x${prefix}" = "xNONE"; then - cat >> confdefs.h <> confdefs.h <> confdefs.h <> confdefs.h <> confdefs.h <> confdefs.h < - --#define CTRL_RETRIES 50 --#define CTRL_TIMEOUT 100 /* milliseconds */ -+#define CTRL_RETRIES 2 -+#define CTRL_TIMEOUT (5*1000) /* milliseconds */ - - #define USB_DT_CS_DEVICE 0x21 - #define USB_DT_CS_CONFIG 0x22 -@@ -106,7 +106,6 @@ static int usb_control_msg(int fd, u_int - ctrl.value = value; - ctrl.index = index; - ctrl.length = size; -- ctrl.timeout = 1000; - ctrl.data = data; - ctrl.timeout = CTRL_TIMEOUT; - try = 0; -@@ -119,10 +118,11 @@ static int usb_control_msg(int fd, u_int - - /* ---------------------------------------------------------------------- */ - -+static int dev_has_strings; -+ - static int get_string(int fd, char *buf, size_t size, u_int8_t id, u_int16_t lang) - { - unsigned char b[256]; -- wchar_t w[128]; - unsigned int i; - int ret; - -@@ -133,17 +133,38 @@ static int get_string(int fd, char *buf, - if (!id || fd == -1) - return 0; - -- b[0] = b[1] = 0xbf; -- ret = usb_control_msg(fd, USB_DIR_IN, USB_REQ_GET_DESCRIPTOR, (USB_DT_STRING << 8) | id, 0, sizeof(b), b); -+ b[0] = b[1] = 0; -+ -+ /* try reading all at once ... some devices misbehave here */ -+ ret = usb_control_msg(fd, USB_DIR_IN, USB_REQ_GET_DESCRIPTOR, (USB_DT_STRING << 8) | id, lang, sizeof(b), b); -+ if (ret > 0) -+ goto got_all; -+ -+ /* read string length first ... most devices handle this ok */ -+ ret = usb_control_msg(fd, USB_DIR_IN, USB_REQ_GET_DESCRIPTOR, (USB_DT_STRING << 8) | id, lang, 2, b); -+ if (ret < 0) { -+ if (open_mode == O_RDWR) -+ fprintf(stderr, "cannot peek string descriptor %d, error = %s(%d)\n", id, strerror(errno), errno); -+ return 0; -+ } -+ if (ret < 2 || b[0] < 2 || b[1] != USB_DT_STRING) { -+ fprintf(stderr, "string descriptor %d invalid (%02x %02x; len=%d)\n", id, b[0], b[1], ret); -+ return 0; -+ } -+ -+ ret = usb_control_msg(fd, USB_DIR_IN, USB_REQ_GET_DESCRIPTOR, (USB_DT_STRING << 8) | id, lang, b[0], b); - if (ret < 0) { - if (open_mode == O_RDWR) - fprintf(stderr, "cannot get string descriptor %d, error = %s(%d)\n", id, strerror(errno), errno); - return 0; - } -+ -+got_all: - if (ret < 2 || b[0] < 2 || b[1] != USB_DT_STRING) { - fprintf(stderr, "string descriptor %d invalid (%02x %02x; len=%d)\n", id, b[0], b[1], ret); - return 0; - } -+ dev_has_strings = 1; - #if 0 - for (i = 0; i < ((b[0] - 2) / 2); i++) - w[i] = b[2+2*i] | (b[3+2*i] << 8); -@@ -151,7 +172,9 @@ static int get_string(int fd, char *buf, - return wcstombs(buf, w, size); - #else - for (i = 0; i < ((b[0] - 2) / 2); i++) -- buf[i] = b[2+2*i]; -+ buf[i] = b[3+2*i] -+ ? '?' /* character's not available in iso-8859/1 */ -+ : b[2+2*i]; - buf[i] = 0; - return i; - #endif -@@ -297,21 +320,25 @@ static void dump_device(int fd, unsigned - dump_junk(buf, " ", 18); - } - --static void dump_config(int fd, unsigned char *buf) -+static void dump_config(int fd, unsigned char *buf, u_int16_t lang) - { -+ char str[128]; -+ - if (buf[1] != USB_DT_CONFIG) - printf(" Warning: Invalid descriptor\n"); - else if (buf[0] < 9) - printf(" Warning: Descriptor too short\n"); -+ get_string(fd, str, sizeof(str), buf[6], lang); - printf(" Configuration Descriptor:\n" - " bLength %5u\n" - " bDescriptorType %5u\n" - " wTotalLength %5u\n" - " bNumInterfaces %5u\n" - " bConfigurationValue %5u\n" -- " iConfiguration %5u\n" -+ " iConfiguration %5u %s\n" - " bmAttributes 0x%02x\n", -- buf[0], buf[1], buf[2] | (buf[3] << 8), buf[4], buf[5], buf[6], buf[7]); -+ buf[0], buf[1], buf[2] | (buf[3] << 8), buf[4], buf[5], -+ buf[6], str, buf[7]); - if (buf[7] & 0x40) - printf(" Self Powered\n"); - if (buf[7] & 0x20) -@@ -352,6 +379,9 @@ static void dump_endpoint(int fd, unsign - { - static const char *typeattr[] = { "Control", "Isochronous", "Bulk", "Interrupt" }; - static const char *syncattr[] = { "none", "Asynchronous", "Adaptive", "Synchronous" }; -+ static const char *usage[] = { "Data", "Feedback", "Implicit feedback Data", "(reserved)" }; -+ static const char *hb[] = { "once", "twice", "three times", "(?)" }; -+ unsigned wMaxPacket = buf[4] | (buf[5] << 8); - - if (buf[1] != USB_DT_ENDPOINT) - printf(" Warning: Invalid descriptor\n"); -@@ -364,15 +394,19 @@ static void dump_endpoint(int fd, unsign - " bmAttributes %5u\n" - " Transfer Type %s\n" - " Synch Type %s\n" -- " wMaxPacketSize %5u\n" -+ " Usage Type %s\n" -+ " wMaxPacketSize 0x%04x bytes %d %s\n" - " bInterval %5u\n", - buf[0], buf[1], buf[2], buf[2] & 15, (buf[2] & 0x80) ? "IN" : "OUT", - buf[3], typeattr[buf[3] & 3], syncattr[(buf[3] >> 2) & 3], -- buf[4] | (buf[5] << 8), buf[6]); -+ usage[(buf[3] >> 4) & 3], -+ wMaxPacket, wMaxPacket & 0x3ff, hb [(wMaxPacket >> 11) & 3], -+ buf[6]); - if (buf[0] < 9) { - dump_junk(buf, " ", 7); - return; - } -+ /* only for audio endpoints */ - printf(" bRefresh %5u\n" - " bSynchAddress %5u\n", - buf[7], buf[8]); -@@ -1017,23 +1051,53 @@ static void dump_midistreaming_endpoint( - dump_junk(buf, " ", 4+buf[3]); - } - -- --static void dump_hub(char *p) -+static void dump_hub(char *prefix, unsigned char *p, int has_tt) - { - unsigned int l, i, j; -+ unsigned wHubChar = (p[4] << 8) | p[3]; - -- printf(" Hub Descriptor:\n"); -- printf(" bLength %3u\n",p[0]); -- printf(" bDesriptorType %3u\n",p[1]); -- printf(" nNbrPorts %3u\n",p[2]); -- printf(" wHubCharacteristic 0x%02x 0x%02x\n", p[3],p[4]); -- printf(" bPwrOn2PwrGood %3u * 2 milli seconds\n",p[5]); -- printf(" bHubContrCurrent %3u milli Ampere\n",p[6]); -+ printf("%sHub Descriptor:\n", prefix); -+ printf("%s bLength %3u\n", prefix, p[0]); -+ printf("%s bDescriptorType %3u\n", prefix, p[1]); -+ printf("%s nNbrPorts %3u\n", prefix, p[2]); -+ printf("%s wHubCharacteristic 0x%04x\n", prefix, wHubChar); -+ switch (wHubChar & 0x03) { -+ case 0: -+ printf("%s Ganged power switching\n", prefix); -+ break; -+ case 1: -+ printf("%s Per-port power switching\n", prefix); -+ break; -+ default: -+ printf("%s No power switching (usb 1.0)\n", prefix); -+ break; -+ } -+ if (wHubChar & 0x04) -+ printf("%s Compound device\n", prefix); -+ switch ((wHubChar >> 3) & 0x03) { -+ case 0: -+ printf("%s Ganged overcurrent protection\n", prefix); -+ break; -+ case 1: -+ printf("%s Per-port overcurrent protection\n", prefix); -+ break; -+ default: -+ printf("%s No overcurrent protection\n", prefix); -+ break; -+ } -+ if (has_tt) { -+ l = (wHubChar >> 5) & 0x03; -+ printf("%s TT think time %d FS bits\n", prefix, (l + 1) * 8); -+ } -+ if (wHubChar & (1<<7)) -+ printf("%s Port indicators\n", prefix); -+ printf("%s bPwrOn2PwrGood %3u * 2 milli seconds\n", prefix, p[5]); -+ printf("%s bHubContrCurrent %3u milli Ampere\n", prefix, p[6]); - l= (p[2] >> 3) + 1; /* this determines the variable number of bytes following */ -- printf(" DeviceRemovable "); -+ printf("%s DeviceRemovable ", prefix); - for(i = 0; i < l; i++) - printf(" 0x%02x", p[7+i]); -- printf("\n PortPwrCtrlMask "); -+ printf("\n%s PortPwrCtrlMask ", prefix); - for(j = 0; j < l; j++) - printf(" 0x%02x ", p[7+i+j]); - printf("\n"); -@@ -1047,7 +1111,7 @@ static void dump_hub(char *p) - - static void dump_report_desc(unsigned char *b, int l) - { -- unsigned int t, j, bsize, btag, btype, data, hut; -+ unsigned int t, j, bsize, btag, btype, data = 1000, hut = 1000; - int i; - char *types[4] = { "Main", "Global", "Local", "reserved" }; - char indent[] = " "; -@@ -1168,21 +1232,131 @@ static void dump_hid_device(int fd, unsi - } - } - -+static char * -+dump_comm_descriptor(int fd, unsigned char *buf, char *indent, u_int16_t lang) -+{ -+ int tmp; -+ char str [128]; -+ -+ switch (buf[2]) { -+ case 0: -+ if (buf[0] != 5) -+ goto bad; -+ printf( "%sCDC Header:\n" -+ "%s bcdCDC %x.%02x\n", -+ indent, -+ indent, buf[4], buf[3]); -+ break; -+ case 0x01: /* call management functional desc */ -+ if (buf [0] != 5) -+ goto bad; -+ printf( "%sCDC Call Management:\n" -+ "%s bmCapabilities 0x%02x\n", -+ indent, -+ indent, buf[3]); -+ if (buf[3] & 0x01) -+ printf( "%s call management\n", indent); -+ if (buf[3] & 0x02) -+ printf( "%s use DataInterface\n", indent); -+ printf("%s bDataInterface %d\n", indent, buf[4]); -+ break; -+ case 0x02: /* acm functional desc */ -+ if (buf [0] != 4) -+ goto bad; -+ printf( "%sCDC ACM:\n" -+ "%s bmCapabilities %02x\n", -+ indent, -+ indent, buf[3]); -+ if (buf[3] & 0x08) -+ printf( "%s connection notifications\n", indent); -+ if (buf[3] & 0x04) -+ printf( "%s sends break\n", indent); -+ if (buf[3] & 0x02) -+ printf( "%s line coding and serial state\n", indent); -+ if (buf[3] & 0x01) -+ printf( "%s get/set/clear comm features\n", indent); -+ break; -+ case 0x06: /* union desc */ -+ if (buf [0] < 5) -+ goto bad; -+ printf( "%sCDC Union:\n" -+ "%s bMasterInterface %d\n" -+ "%s bSlaveInterface ", -+ indent, -+ indent, buf [3], -+ indent); -+ for (tmp = 4; tmp < buf [0]; tmp++) -+ printf("%d ", buf [tmp]); -+ printf("\n"); -+ break; -+ case 0x0f: /* ethernet functional desc */ -+ if (buf [0] != 13) -+ goto bad; -+ get_string(fd, str, sizeof str, buf[3], lang); -+ tmp = buf [7] << 8; -+ tmp |= buf [6]; tmp <<= 8; -+ tmp |= buf [5]; tmp <<= 8; -+ tmp |= buf [4]; -+ printf( "%sCDC Ethernet:\n" -+ "%s iMacAddress %d %s\n" -+ "%s bmEthernetStatistics 0x%08x\n", -+ indent, -+ indent, buf[3], (buf[3] && *str) ? str : "(?)", -+ indent, tmp); -+ /* FIXME dissect ALL 28 bits */ -+ printf( "%s wMaxSegmentSize %d\n" -+ "%s wNumberMCFilters 0x%04x\n" -+ "%s bNumberPowerFilters %d\n", -+ indent, (buf[9]<<8)|buf[8], -+ indent, (buf[11]<<8)|buf[10], -+ indent, buf[12]); -+ break; -+ /* FIXME there are about a dozen more descriptor types */ -+ default: -+ return "unsupported comm descriptor"; -+ } -+ return 0; -+ -+bad: -+ return "corrupt comm descriptor"; -+} -+ - /* ---------------------------------------------------------------------- */ - -+static void do_hub(int fd, int has_tt) -+{ -+ unsigned char buf [7]; -+ int ret; -+ -+ ret = usb_control_msg(fd, USB_DIR_IN | USB_TYPE_CLASS, -+ USB_REQ_GET_DESCRIPTOR, 0x29 << 8, 0, -+ sizeof buf, buf); -+ if (ret != sizeof buf) { -+ perror ("can't get hub descriptor"); -+ return; -+ } -+ dump_hub("", buf, has_tt); -+} -+ - static void do_config(int fd, unsigned int nr, u_int16_t lang) - { -- unsigned char buf[1024],*p; -- unsigned int sz,curinterface; -- int l; -+ unsigned char buf[1024],*p, *err; -+ unsigned int sz,curinterface = 1000; - u_int8_t curclass = 0xff, cursubclass = 0xff; -+ unsigned retries = 0; - -+ for (;;) { - if (usb_control_msg(fd, USB_DIR_IN, USB_REQ_GET_DESCRIPTOR, (USB_DT_CONFIG << 8) | nr, - 0, USB_DT_CONFIG_SIZE, buf) < 0) { -+ if (retries++ >= 5) { - if (open_mode == O_RDWR) - fprintf(stdout, "cannot get config descriptor %d, %s (%d)\n", nr, strerror(errno), errno); - return; -+ } -+ continue; -+ } else break; - } -+ - if (buf[0] < USB_DT_CONFIG_SIZE || buf[1] != USB_DT_CONFIG) - fprintf(stderr, "Warning: invalid config descriptor\n"); - sz = buf[2] | buf[3] << 8; -@@ -1208,13 +1382,14 @@ static void do_config(int fd, unsigned i - } - switch (p[1]) { - case USB_DT_DEVICE: -+ /* NOTE: should NOT be found here! */ - dump_device(fd, p, lang); - curclass = p[4]; - cursubclass = p[5]; - break; - - case USB_DT_CONFIG: -- dump_config(fd, p); -+ dump_config(fd, p, lang); - break; - - case USB_DT_INTERFACE: -@@ -1229,39 +1404,39 @@ static void do_config(int fd, unsigned i - break; - - case USB_DT_CS_DEVICE: -- if (curclass == 3) { -+ if (curclass == USB_CLASS_HID) { - dump_hid_device(fd, p, curinterface); - break; - } -- printf(" unknown descriptor type:"); -- dump_junk2(p, p[0]); -- break; -- -- case USB_DT_CS_CONFIG: -- printf(" unknown descriptor type:"); -- dump_junk2(p, p[0]); -- break; -- -- case USB_DT_CS_STRING: -- printf(" unknown descriptor type:"); -- dump_junk2(p, p[0]); -- break; -+ err = "unknown device class descriptor"; -+ goto junk; - - case USB_DT_CS_INTERFACE: -- if (curclass == 1 && cursubclass == 1) { -- dump_audiocontrol_interface(fd, p, lang); -+ err = "unknown interface class descriptor"; -+ switch (curclass) { -+ case USB_CLASS_AUDIO: -+ switch (cursubclass) { -+ case 1: -+ dump_audiocontrol_interface(fd, p, lang); -+ break; -+ case 2: -+ dump_audiostreaming_interface(fd, p); -+ break; -+ case 3: -+ dump_midistreaming_interface(fd, p, lang); -+ break; -+ default: -+ goto junk; -+ } - break; -- } -- if (curclass == 1 && cursubclass == 2) { -- dump_audiostreaming_interface(fd, p); -- break; -- } -- if (curclass == 1 && cursubclass == 3) { -- dump_midistreaming_interface(fd, p, lang); -+ case USB_CLASS_COMM: -+ err = dump_comm_descriptor (fd, p, " ", lang); -+ if (err) -+ goto junk; - break; -+ default: -+ goto junk; - } -- printf(" unknown descriptor type:"); -- dump_junk2(p, p[0]); - break; - - case USB_DT_CS_ENDPOINT: -@@ -1273,16 +1448,20 @@ static void do_config(int fd, unsigned i - dump_midistreaming_endpoint(fd, p); - break; - } -- printf(" unknown descriptor type:"); -- dump_junk2(p, p[0]); -- break; -+ err = "unknown endpoint class descriptor"; -+ goto junk; - - case USB_DT_HUB: -- dump_hub(p); -+ /* NOTE only rather ancient hubs will include -+ * this with the config descriptor. -+ */ -+ dump_hub(" ", p, 0); - break; - - default: -- printf(" unknown descriptor type:"); -+ err = "unknown descriptor type"; -+junk: -+ printf(" %s:", err); - dump_junk2(p, p[0]); - } - sz -= p[0]; -@@ -1303,21 +1482,41 @@ static u_int16_t dump_langids(int fd, in - int i, l; - u_int16_t lang; - -- b[0] = b[1] = 0xbf; -- l = usb_control_msg(fd, USB_DIR_IN, USB_REQ_GET_DESCRIPTOR, USB_DT_STRING << 8, 0, sizeof(b), b); -+ /* read string length first, like recent linuxes -- else some devices misbehave */ -+ b[0] = b[1] = 0; -+ l = usb_control_msg(fd, USB_DIR_IN, USB_REQ_GET_DESCRIPTOR, USB_DT_STRING << 8, 0, 4, b); - -+ if (l < 0 && errno == EPIPE) -+ l = 0; - if (l < 0) { -- if (open_mode == O_RDWR) -+ if (open_mode == O_RDWR && !quiet) - printf(" Language IDs: none (cannot get min. string descriptor; got len=%d, error=%d:%s)\n", - l, errno, strerror(errno)); - return 0; - } -- if (l < 4 || b[0] != l) { -+ if (l == 0) { -+ if (!quiet) -+ printf(" Language IDs: none\n"); -+ return 0; -+ } -+ if (l < 4) { -+ if (!quiet) - printf(" Language IDs: none (invalid length string descriptor %02x; len=%d)\n", b[0], l); - return 0; - } - /* save first language ID for further get_string_descriptors */ - lang = b[2] | (b[3] << 8); -+ -+ /* maybe there's more than one */ -+ if (b[0] > 4) { -+ l = usb_control_msg(fd, USB_DIR_IN, USB_REQ_GET_DESCRIPTOR, USB_DT_STRING << 8, 0, b[0], b); -+ if (l < 4 || b[0] != l) { -+ fprintf(stderr, "string 0 broken re-read, l = %d, b[0] = %d \n", l, b[0]); -+ b[0] = 4; -+ b[2] = lang; -+ b[3] = lang >> 8; -+ } -+ } - #if 0 - printf ("dump_langids: ret=%d:%d, lang=0x%x, length=%d\n", l, errno, lang, b[0]); - dump_junk2 (b, 32); -@@ -1342,11 +1541,17 @@ static void dumpdev(unsigned char *devde - maxcfg = devdesc[17]; - if (devdesc[0] < 18 || devdesc[1] != USB_DT_DEVICE) - maxcfg = 1; -+ dev_has_strings = 0; - lang = dump_langids(fd, 1); - dump_device(fd, devdesc, lang); - for (i = 0; i < maxcfg; i++) - do_config(fd, i, lang); -- lang = dump_langids(fd, 0); -+ if (devdesc[4] == USB_CLASS_HUB) -+ do_hub(fd, devdesc [6]); -+ /* FIXME if it's usb 2.0 and there's a device qualifier, -+ * optionally dump it and the other-speed config data -+ */ -+ lang = dump_langids(fd, !dev_has_strings); - } - - /* ---------------------------------------------------------------------- */ -@@ -1560,7 +1765,7 @@ int main(int argc, char *argv[]) - exit(1); - } - if ((err = names_init("./usb.ids")) != 0) -- if(err = names_init(USBIDS_FILE)) { -+ if((err = names_init(USBIDS_FILE)) != 0) { - printf("Error, cannot open USBIDS File \"%s\", %s\n", USBIDS_FILE, strerror(err)); - exit(1); - }