-----BEGIN PGP SIGNATURE-----

Version: GnuPG v2.0.22 (GNU/Linux)
 
 iQIcBAABAgAGBQJZSpQSAAoJEEy22O7T6HE4zxgP/3SSjpgTn7dVbnCe9UuZ+n9A
 WvjzxidVm4FMtpt6ILsyf0ZU7ky+YO3jas54ngqnWFb31H5MnQohhnVM/Jlkg5aa
 w3Pe4J6KF0vQozTMcj7ZAQAEUJhbPCqctTRSngTG8LtAH25al9NBj0EvAusf5Q4E
 JmSH8WyFuYws/O9OQnAg/esvYZ/1g5MZy+XHDOMnnJQCSB9x+Q8Frved/XN2KhoS
 UIfqAqn/9s2glwOqGyG6KCZGpgk/V3KuDOgXbxiDM95fZX6CiNKyVWDmVNOUYClg
 CIdWkE720iq+kj2xP1Q1QyWzZr4iSBREwZ37DfgBYLgu3i1QWNPsQCpKncQE8nIk
 sSR+J4AE5omTjyR4Bu+oFqGcF/bieysXWK/VjEbmq6UJ3/10eMpQijGvOF2VxsUS
 rVnizE+BdQojsVWPXLN2l3tUs6v4TDClXiu6D0M/FlShiKU5wccmArKoF+ipzA/n
 tueZcwTiSZ6YbSbBa7m/U3WNl8Vh6yOoaGndX4R7uJ/bX1Eld4OaTGJJ1NbpTNlA
 ESEzohn5SMLBlMOC1J1mDld3z0CqmlGUmRUUB8lQt5bHF0lSPQ5we9ZiHcK4pmmT
 DJIkus+45REQJ1eqNhZsbvpEpUKoRws2JQq+nsb0Jrr7sMEMv404cm0eI0e12OdI
 aJwhowDec4mDK9DSjyUB
 =zplk
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/kraxel/tags/usb-20170621-pull-request' into staging

# gpg: Signature made Wed 21 Jun 2017 16:43:14 BST
# gpg:                using RSA key 0x4CB6D8EED3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>"
# gpg:                 aka "Gerd Hoffmann <gerd@kraxel.org>"
# gpg:                 aka "Gerd Hoffmann (private) <kraxel@gmail.com>"
# Primary key fingerprint: A032 8CFF B93A 17A7 9901  FE7D 4CB6 D8EE D3E8 7138

* remotes/kraxel/tags/usb-20170621-pull-request:
  usb-host: support devices with sparse/non-sequential USB interfaces

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2017-06-22 15:09:48 +01:00
commit e18a639164

View File

@ -1107,7 +1107,7 @@ static void usb_host_detach_kernel(USBHostDevice *s)
if (rc != 0) {
return;
}
for (i = 0; i < conf->bNumInterfaces; i++) {
for (i = 0; i < USB_MAX_INTERFACES; i++) {
rc = libusb_kernel_driver_active(s->dh, i);
usb_host_libusb_error("libusb_kernel_driver_active", rc);
if (rc != 1) {
@ -1130,7 +1130,7 @@ static void usb_host_attach_kernel(USBHostDevice *s)
if (rc != 0) {
return;
}
for (i = 0; i < conf->bNumInterfaces; i++) {
for (i = 0; i < USB_MAX_INTERFACES; i++) {
if (!s->ifs[i].detached) {
continue;
}
@ -1145,7 +1145,7 @@ static int usb_host_claim_interfaces(USBHostDevice *s, int configuration)
{
USBDevice *udev = USB_DEVICE(s);
struct libusb_config_descriptor *conf;
int rc, i;
int rc, i, claimed;
for (i = 0; i < USB_MAX_INTERFACES; i++) {
udev->altsetting[i] = 0;
@ -1164,14 +1164,19 @@ static int usb_host_claim_interfaces(USBHostDevice *s, int configuration)
return USB_RET_STALL;
}
for (i = 0; i < conf->bNumInterfaces; i++) {
claimed = 0;
for (i = 0; i < USB_MAX_INTERFACES; i++) {
trace_usb_host_claim_interface(s->bus_num, s->addr, configuration, i);
rc = libusb_claim_interface(s->dh, i);
usb_host_libusb_error("libusb_claim_interface", rc);
if (rc != 0) {
return USB_RET_STALL;
if (rc == 0) {
s->ifs[i].claimed = true;
if (++claimed == conf->bNumInterfaces) {
break;
}
}
s->ifs[i].claimed = true;
}
if (claimed != conf->bNumInterfaces) {
return USB_RET_STALL;
}
udev->ninterfaces = conf->bNumInterfaces;
@ -1183,10 +1188,9 @@ static int usb_host_claim_interfaces(USBHostDevice *s, int configuration)
static void usb_host_release_interfaces(USBHostDevice *s)
{
USBDevice *udev = USB_DEVICE(s);
int i, rc;
for (i = 0; i < udev->ninterfaces; i++) {
for (i = 0; i < USB_MAX_INTERFACES; i++) {
if (!s->ifs[i].claimed) {
continue;
}