summaryrefslogtreecommitdiff
path: root/usb-linux.c
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2011-08-30 13:21:27 +0200
committerGerd Hoffmann <kraxel@redhat.com>2012-01-13 10:25:44 +0100
commit1de14d43e29b8f1fff8bcbf18f300adeb3eabc1d (patch)
tree206e160d56c1380a4cbb71e3e2f93854ab7fb87e /usb-linux.c
parent65360511a2eeab8b671722df6634dd674cc4a5d6 (diff)
usb: track altsetting in USBDevice
Also handle {GET,SET}_INTERFACE in common code (usb-desc.c). Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'usb-linux.c')
-rw-r--r--usb-linux.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/usb-linux.c b/usb-linux.c
index 3aaa93bd86..ded0726dad 100644
--- a/usb-linux.c
+++ b/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;
}