mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-01 23:03:54 -06:00
usb: track altsetting in USBDevice
Also handle {GET,SET}_INTERFACE in common code (usb-desc.c). Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
parent
65360511a2
commit
1de14d43e2
12 changed files with 90 additions and 79 deletions
10
usb-linux.c
10
usb-linux.c
|
@ -544,6 +544,10 @@ static int usb_host_claim_interfaces(USBHostDevice *dev, int configuration)
|
|||
int interface, nb_interfaces;
|
||||
int ret, i;
|
||||
|
||||
for (i = 0; i < USB_MAX_INTERFACES; i++) {
|
||||
dev->dev.altsetting[i] = 0;
|
||||
}
|
||||
|
||||
if (configuration == 0) { /* address state - ignore */
|
||||
dev->dev.ninterfaces = 0;
|
||||
dev->dev.configuration = 0;
|
||||
|
@ -997,6 +1001,10 @@ static int usb_host_set_interface(USBHostDevice *s, int iface, int alt)
|
|||
}
|
||||
}
|
||||
|
||||
if (iface >= USB_MAX_INTERFACES) {
|
||||
return USB_RET_STALL;
|
||||
}
|
||||
|
||||
si.interface = iface;
|
||||
si.altsetting = alt;
|
||||
ret = ioctl(s->fd, USBDEVFS_SETINTERFACE, &si);
|
||||
|
@ -1007,6 +1015,8 @@ static int usb_host_set_interface(USBHostDevice *s, int iface, int alt)
|
|||
if (ret < 0) {
|
||||
return ctrl_error();
|
||||
}
|
||||
|
||||
s->dev.altsetting[iface] = alt;
|
||||
usb_linux_update_endp_table(s);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue