From 93da4c3dcf6a7f9da5615e37e6c8cf640c3ade04 Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Fri, 21 Jan 2005 18:38:19 +0000 Subject: [PATCH] Add patch to work around the fact that the kernel gives us a device descriptor with four fields (and _only_ those four fields) already byteswapped. This behaviour, although insane, needs to stay because libusb already copes with it. --- usbutils-0.11-endian.patch | 60 ++++++++++++++++++++++++++++++++++++++ usbutils.spec | 7 ++++- 2 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 usbutils-0.11-endian.patch diff --git a/usbutils-0.11-endian.patch b/usbutils-0.11-endian.patch new file mode 100644 index 0000000..8358a42 --- /dev/null +++ b/usbutils-0.11-endian.patch @@ -0,0 +1,60 @@ +--- 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.spec b/usbutils.spec index ce5a6df..dbc71c1 100644 --- a/usbutils.spec +++ b/usbutils.spec @@ -1,10 +1,11 @@ Name: usbutils Version: 0.11 -Release: 6.1 +Release: 6.2 Source: http://usb.cs.tum.edu/download/%{name}-%{version}.tar.gz Patch: usbutils-0.9-hwdata.patch Patch2: usbutils-0214.patch Patch3: usbutils-0.11-hidcc.patch +Patch4: usbutils-0.11-endian.patch License: GPL BuildRoot: %{_tmppath}/%{name}-%{version}-root Requires: hwdata @@ -23,6 +24,7 @@ USB bus. %patch -p1 -b .hwdata %patch2 -p1 -b .0214 %patch3 -p1 -b .hidcc +%patch4 -p1 -b .endian %build cp /usr/share/libtool/config.{sub,guess} . @@ -50,6 +52,9 @@ rm -f $RPM_BUILD_ROOT%{_datadir}/usb.ids rm -rf $RPM_BUILD_ROOT %changelog +* Thu Jan 20 2005 David Woodhouse 0.11-6.2 +- Don't byteswap parts of device descriptor which kernel already swapped + * Mon Sep 13 2004 Thomas Woerner 0.11-6.1 - added missing BuildRequires for libtool (#132406)