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

Submitted by Uri Lublin on July 5, 2012, 8:44 p.m.

Details

Message ID 1341521049-4562-13-git-send-email-uril@redhat.com
State New
Headers show

Not browsing as part of any series.

Commit Message

Uri Lublin July 5, 2012, 8:44 p.m.
---
 gtk/usb-device-manager.c |   15 +++++----------
 1 files changed, 5 insertions(+), 10 deletions(-)

Patch hide | download patch | download mbox

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;
 }