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));
Attachment:
signature.asc
Description: PGP signature
_______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel