[Spice-devel] [spice-gtk 10/13] win-usb-dev: maintain list of libusb devices
Christophe Fergeau
cfergeau at redhat.com
Tue Mar 12 17:32:14 UTC 2019
On Sun, Mar 10, 2019 at 04:46:09PM +0200, Yuri Benditovich wrote:
> @@ -388,18 +402,20 @@ static gboolean get_usb_dev_info(libusb_device *dev, GUdevDeviceInfo *udevinfo)
> }
>
> /* comparing bus:addr and vid:pid */
> -static gint gudev_devices_differ(gconstpointer a, gconstpointer b)
> +static gint compare_libusb_devices(gconstpointer a, gconstpointer b)
> {
> - GUdevDeviceInfo *ai, *bi;
> + libusb_device *a_dev = (libusb_device *)a;
> + libusb_device *b_dev = (libusb_device *)b;
> + struct libusb_device_descriptor a_desc, b_desc;
> gboolean same_bus, same_addr, same_vid, same_pid;
>
> - ai = G_UDEV_DEVICE(a)->priv->udevinfo;
> - bi = G_UDEV_DEVICE(b)->priv->udevinfo;
> + libusb_get_device_descriptor(a_dev, &a_desc);
> + libusb_get_device_descriptor(b_dev, &b_desc);
>
> - same_bus = (ai->bus == bi->bus);
> - same_addr = (ai->addr == bi->addr);
> - same_vid = (ai->vid == bi->vid);
> - same_pid = (ai->pid == bi->pid);
> + same_bus = libusb_get_bus_number(a_dev) == libusb_get_bus_number(b_dev);
> + same_addr = libusb_get_device_address(a_dev) == libusb_get_device_address(b_dev);
> + same_vid = (a_desc.idVendor == b_desc.idVendor);
> + same_pid = (a_desc.idProduct == b_desc.idProduct);
Sorry I forgot to mention this before, but I'd keep () around same_bus
and same_addr tests:
+ same_bus = (libusb_get_bus_number(a_dev) == libusb_get_bus_number(b_dev));
+ same_addr = (libusb_get_device_address(a_dev) == libusb_get_device_address(b_dev));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20190312/02877cc8/attachment.sig>
More information about the Spice-devel
mailing list