[Spice-devel] [spice-gtk Win32 v4 12/17] usb-device-manager: use find_device() in libdev_to_device()

Uri Lublin uril at redhat.com
Thu Jul 5 13:44:04 PDT 2012


---
 gtk/usb-device-manager.c |   15 +++++----------
 1 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/gtk/usb-device-manager.c b/gtk/usb-device-manager.c
index 3fec521..53a3794 100644
--- a/gtk/usb-device-manager.c
+++ b/gtk/usb-device-manager.c
@@ -1414,17 +1414,12 @@ static SpiceUsbDevice *
 spice_usb_device_manager_libdev_to_device(SpiceUsbDeviceManager *self,
                                           libusb_device *libdev)
 {
-    SpiceUsbDeviceManagerPrivate *priv = self->priv;
-    SpiceUsbDevice *device = NULL;
-    int i;
+    SpiceUsbDevice *device;
+    guint8 bus, addr;

-    for (i = 0; i < priv->devices->len; i++) {
-        device = g_ptr_array_index(priv->devices, i);
-        if (spice_usb_device_equal_libdev(device, libdev)) {
-            break; /* found it */
-        }
-        device = NULL; /* did not find it yet */
-    }
+    bus  = libusb_get_bus_number(libdev);
+    addr = libusb_get_device_address(libdev);
+    device = spice_usb_device_manager_find_device(self, bus, addr);
     return device;
 }

-- 
1.7.7.6



More information about the Spice-devel mailing list