[Spice-commits] 2 commits - src/usb-device-manager.c
Pavel Grunt
pgrunt at kemper.freedesktop.org
Thu Feb 18 07:47:14 UTC 2016
src/usb-device-manager.c | 20 +++++---------------
1 file changed, 5 insertions(+), 15 deletions(-)
New commits:
commit f84ae99f82c4c9f53ffb18c4740505a93256859d
Author: Christophe Fergeau <cfergeau at redhat.com>
Date: Thu Feb 11 18:04:46 2016 +0200
Simplify spice_usb_device_manager_device_to_libdev()
The Windows-specific version duplicates some code from
spice_usb_device_equal_libdev(), this commit
switches to using that helper instead.
diff --git a/src/usb-device-manager.c b/src/usb-device-manager.c
index fab919f..a3aa014 100644
--- a/src/usb-device-manager.c
+++ b/src/usb-device-manager.c
@@ -1935,7 +1935,6 @@ spice_usb_device_manager_device_to_libdev(SpiceUsbDeviceManager *self,
*/
libusb_device *d, **devlist;
- int bus, addr;
int i;
g_return_val_if_fail(SPICE_IS_USB_DEVICE_MANAGER(self), NULL);
@@ -1943,16 +1942,12 @@ spice_usb_device_manager_device_to_libdev(SpiceUsbDeviceManager *self,
g_return_val_if_fail(self->priv != NULL, NULL);
g_return_val_if_fail(self->priv->context != NULL, NULL);
- /* On windows we match by vid / pid, since the address may change */
- bus = spice_usb_device_get_vid(device);
- addr = spice_usb_device_get_pid(device);
-
libusb_get_device_list(self->priv->context, &devlist);
if (!devlist)
return NULL;
for (i = 0; (d = devlist[i]) != NULL; i++) {
- if (spice_usb_device_manager_libdev_match(d, bus, addr)) {
+ if (spice_usb_device_equal_libdev(device, d)) {
libusb_ref_device(d);
break;
}
commit 7c85f88f265664c424c368b12d3a0f117beadf54
Author: Christophe Fergeau <cfergeau at redhat.com>
Date: Thu Feb 11 18:04:45 2016 +0200
Simplify spice_usb_device_equal_libdev()
The Windows-specific version duplicates some code from
spice_usb_device_manager_libdev_match(), this commit
switches to using that helper instead.
diff --git a/src/usb-device-manager.c b/src/usb-device-manager.c
index 6e12602..fab919f 100644
--- a/src/usb-device-manager.c
+++ b/src/usb-device-manager.c
@@ -1907,19 +1907,14 @@ static gboolean
spice_usb_device_equal_libdev(SpiceUsbDevice *device,
libusb_device *libdev)
{
- int vid1, vid2, pid1, pid2;
+ int vid, pid;
if ((device == NULL) || (libdev == NULL))
return FALSE;
- vid1 = spice_usb_device_get_vid(device);
- pid1 = spice_usb_device_get_pid(device);
-
- if (!spice_usb_device_manager_get_libdev_vid_pid(libdev, &vid2, &pid2)) {
- return FALSE;
- }
-
- return ((vid1 == vid2) && (pid1 == pid2));
+ vid = spice_usb_device_get_vid(device);
+ pid = spice_usb_device_get_pid(device);
+ return spice_usb_device_manager_libdev_match(libdev, vid, pid);
}
#endif
More information about the Spice-commits
mailing list