rendered paste body===================================================================
--- usb-linux.c
+++ usb-linux.c 2007-04-28 22:02:15.000000000 +0200
@@ -186,18 +186,13 @@
if (i + config_descr_len > descr_len)
goto fail;
nb_interfaces = descr[i + 4];
- if (nb_interfaces != 1) {
- /* NOTE: currently we grab only one interface */
- fprintf(stderr, "usb_host: only one interface supported\n");
- goto fail;
- }
#ifdef USBDEVFS_DISCONNECT
/* earlier Linux 2.4 do not support that */
- {
+ for(i = 0; i < nb_interfaces; i++) {
struct usbdevfs_ioctl ctrl;
ctrl.ioctl_code = USBDEVFS_DISCONNECT;
- ctrl.ifno = 0;
+ ctrl.ifno = i;
ret = ioctl(fd, USBDEVFS_IOCTL, &ctrl);
if (ret < 0 && errno != ENODATA) {
perror("USBDEVFS_DISCONNECT");
@@ -206,18 +201,19 @@
}
#endif
- /* XXX: only grab if all interfaces are free */
- interface = 0;
- ret = ioctl(fd, USBDEVFS_CLAIMINTERFACE, &interface);
- if (ret < 0) {
- if (errno == EBUSY) {
- fprintf(stderr, "usb_host: device already grabbed\n");
- } else {
- perror("USBDEVFS_CLAIMINTERFACE");
- }
- fail:
- close(fd);
- return NULL;
+ /* XXX: Grab every interfaces */
+ for(interface = 0; interface < nb_interfaces; interface++) {
+ ret = ioctl(fd, USBDEVFS_CLAIMINTERFACE, &interface);
+ if (ret < 0) {
+ if (errno == EBUSY) {
+ fprintf(stderr, "usb_host: device already grabbed\n");
+ } else {
+ perror("USBDEVFS_CLAIMINTERFACE");
+ }
+fail:
+ close(fd);
+ return NULL;
+ }
}
ret = ioctl(fd, USBDEVFS_CONNECTINFO, &ci);