And use it in spice_usb_device_manager_remove_dev --- gtk/usb-device-manager.c | 32 +++++++++++++++++++++----------- 1 files changed, 21 insertions(+), 11 deletions(-) diff --git a/gtk/usb-device-manager.c b/gtk/usb-device-manager.c index d9ed8a7..3fec521 100644 --- a/gtk/usb-device-manager.c +++ b/gtk/usb-device-manager.c @@ -582,6 +582,25 @@ static void spice_usb_device_manager_auto_connect_cb(GObject *gobject, spice_usb_device_unref(device); } +static SpiceUsbDevice* +spice_usb_device_manager_find_device(SpiceUsbDeviceManager *self, + guint8 bus, guint8 address) +{ + SpiceUsbDeviceManagerPrivate *priv = self->priv; + SpiceUsbDevice *curr, *device = NULL; + guint i; + + for (i = 0; i < priv->devices->len; i++) { + curr = g_ptr_array_index(priv->devices, i); + if (spice_usb_device_get_busnum(curr) == bus && + spice_usb_device_get_devaddr(curr) == address) { + device = curr; + break; + } + } + return device; +} + static void spice_usb_device_manager_add_dev(SpiceUsbDeviceManager *self, GUdevDevice *udev) { @@ -661,22 +680,13 @@ static void spice_usb_device_manager_remove_dev(SpiceUsbDeviceManager *self, GUdevDevice *udev) { SpiceUsbDeviceManagerPrivate *priv = self->priv; - SpiceUsbDevice *curr, *device = NULL; + SpiceUsbDevice *device = NULL; int bus, address; - guint i; if (!spice_usb_device_manager_get_udev_bus_n_address(udev, &bus, &address)) return; - for (i = 0; i < priv->devices->len; i++) { - curr = g_ptr_array_index(priv->devices, i); - if (spice_usb_device_get_busnum(curr) == bus && - spice_usb_device_get_devaddr(curr) == address) { - device = curr; - break; - } - } - + device = spice_usb_device_manager_find_device(self, bus, address); if (!device) { g_warning("Could not find USB device to remove at busnum %d devaddr %d", bus, address); -- 1.7.7.6 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/spice-devel