Re: lsusb apparent bogosity

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

 



On Tue, Mar 22, 2011 at 05:26:01PM +1100, Benjamin Herrenschmidt wrote:
> 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

What version of usbutils is this?

> 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 ?

Yes it is. :)

I commented on this a while ago but I got the report that it worked, and
no one else had a BE system, I didn't know what to do, so I left it.

> 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).

Good point, I'll drop this entirely from the current version as we
should be fine now.

thanks,

greg k-h
--
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