lsusb apparent bogosity

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Greg !

I recently noticed that the output from lsusb was utterly wrong on PPC
for 16-bit fields (like bad endianess :)

Digging a bit I noticed a couple of things:

 - My distro (ubuntu, yeah I know how much you love them) variant of
lsusb does:

if (__BYTE_ORDER == __LITTLE_ENDIAN)
  #define le16_to_cpu(x) (x)
#elif (__BYTE_ORDER == __BIG_ENDIAN)
  #define le16_to_cpu(x) bswap_16(x)
#else
  #error missing BYTE_ORDER
#endif

when reading a 16-bit field from a descriptor

 - "Upstream" usbutils does:

#define le16_to_cpu(x) libusb_cpu_to_le16(libusb_cpu_to_le16(x))

Now, the later is obviously crackpot :-) It's really basically a nop
right ?

The fun thing is, this is the -right- thing to do (tho I haven't built &
tried that version yet). The trick is that descriptor structures parsed
by libusb using usb_parse_descriptor and the "w" format will already
have been appropriately byteswapped by libusb itself.

So lsusb should never have to do that swapping again (and gives a bad
example to other programs).

Cheers,
Ben.


--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux