Utility procedure get_usb_device_info_from_libusb_device will be reused later. Signed-off-by: Yuri Benditovich <yuri.benditovich@xxxxxxxxxx> --- src/usb-backend.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/usb-backend.c b/src/usb-backend.c index a33cbe6..c2268e3 100644 --- a/src/usb-backend.c +++ b/src/usb-backend.c @@ -69,27 +69,30 @@ struct _SpiceUsbBackendChannel GError **error; }; -static gboolean fill_usb_info(SpiceUsbBackendDevice *bdev) +static void get_usb_device_info_from_libusb_device(UsbDeviceInformation *info, + libusb_device *libdev) { - UsbDeviceInformation *info = &bdev->device_info; - struct libusb_device_descriptor desc; - libusb_device *libdev = bdev->libusb_device; libusb_get_device_descriptor(libdev, &desc); info->bus = libusb_get_bus_number(libdev); info->address = libusb_get_device_address(libdev); - if (info->address == 0xff || /* root hub (HCD) */ - info->address <= 1 || /* root hub or bad address */ - (desc.bDeviceClass == LIBUSB_CLASS_HUB) /*hub*/) { - return FALSE; - } - info->vid = desc.idVendor; info->pid = desc.idProduct; info->class = desc.bDeviceClass; info->subclass = desc.bDeviceSubClass; info->protocol = desc.bDeviceProtocol; +} +static gboolean fill_usb_info(SpiceUsbBackendDevice *bdev) +{ + UsbDeviceInformation *info = &bdev->device_info; + get_usb_device_info_from_libusb_device(info, bdev->libusb_device); + + if (info->address == 0xff || /* root hub (HCD) */ + info->address <= 1 || /* root hub or bad address */ + (info->class == LIBUSB_CLASS_HUB) /*hub*/) { + return FALSE; + } return TRUE; } -- 2.17.1 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel