On Tue, 17 Aug 2010, John Youn wrote: > > John, I'm concerned that you're blindly assigning the USB 3.0 hub > > descriptor to a usb_hub_descriptor. The current structure is: > > > > struct usb_hub_descriptor { > > __u8 bDescLength; > > __u8 bDescriptorType; > > __u8 bNbrPorts; > > __le16 wHubCharacteristics; > > __u8 bPwrOn2PwrGood; > > __u8 bHubContrCurrent; > > /* add 1 bit for hub status change; round to bytes */ > > __u8 DeviceRemovable[(USB_MAXCHILDREN + 1 + 7) / 8]; > > __u8 PortPwrCtrlMask[(USB_MAXCHILDREN + 1 + 7) / 8]; > > } __attribute__ ((packed)); > > > > The USB 3.0 hub descriptor should look something like this: > > > > struct usb_hub_usb3_descriptor { > > __u8 bDescLength; > > __u8 bDescriptorType; > > __u8 bNbrPorts; > > __le16 wHubCharacteristics; > > __u8 bPwrOn2PwrGood; > > __u8 bHubContrCurrent; > > /* add 1 bit for hub status change; round to bytes */ This comment doesn't belong here. It's present in the USB-2.0 structure because the DeviceRemovable and PortPwrCtrlMask fields have variable length, depending on the number of ports. In the USB-3.0 structure the fields are all fixed length. > > __u8 bHubHdrDecLat; > > __u16 wHubDelay; > > __u8 DeviceRemovable[2]; > > } __attribute__ ((packed)); > > > > The descriptor is longer, and the fields after bHubContrCurrent don't > > align properly. So I don't think your current approach of just > > assigning the new hub descriptor to a pointer of the old hub descriptor > > type is going to work very well. > > > > Actually the 3.0 descriptor is smaller than the largest 2.0 descriptor, so it fits into the same buffer. And most of the structure is the same so I left it like that so the core can access the same structure and fields. > > The differences are only at the end, so for 3.0 hubs I skipped where the hub accesses the 2.0-only fields DeviceRemovable and PortPwrCtrlMask, and put the FIXME comment. For the new 3.0 fields, there is no code to use them yet. > > Not a complete solution obviously but I did somewhat account for the difference. Perhaps the best answer is to use a union. Alan Stern -- 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