> 32 KB packet handling (Ed Swierk)
[qemu] / usb-linux.c
index cde94cd..9cd543d 100644 (file)
@@ -181,10 +181,15 @@ USBDevice *usb_host_device_open(const char *devname)
 
 #ifdef USBDEVFS_DISCONNECT
     /* earlier Linux 2.4 do not support that */
-    ret = ioctl(fd, USBDEVFS_DISCONNECT);
-    if (ret < 0 && errno != ENODATA) {
-        perror("USBDEVFS_DISCONNECT");
-        goto fail;
+    {
+        struct usbdevfs_ioctl ctrl;
+        ctrl.ioctl_code = USBDEVFS_DISCONNECT;
+        ctrl.ifno = 0;
+        ret = ioctl(fd, USBDEVFS_IOCTL, &ctrl);
+        if (ret < 0 && errno != ENODATA) {
+            perror("USBDEVFS_DISCONNECT");
+            goto fail;
+        }
     }
 #endif
 
@@ -273,7 +278,8 @@ static int usb_host_scan(void *opaque, USBScanFunc *func)
         if (strlen(line) > 0)
             line[strlen(line) - 1] = '\0';
         if (line[0] == 'T' && line[1] == ':') {
-            if (device_count) {
+            if (device_count && (vendor_id || product_id)) {
+                /* New device.  Add the previously discovered device.  */
                 ret = func(opaque, bus_num, addr, class_id, vendor_id, 
                            product_id, product_name, speed);
                 if (ret)
@@ -316,7 +322,8 @@ static int usb_host_scan(void *opaque, USBScanFunc *func)
         }
     fail: ;
     }
-    if (device_count) {
+    if (device_count && (vendor_id || product_id)) {
+        /* Add the last device.  */
         ret = func(opaque, bus_num, addr, class_id, vendor_id, 
                    product_id, product_name, speed);
     }