[Spice-devel] [PATCH spice-gtk 05/44] fixup! usb-redir: define interfaces to support emulated devices
Frediano Ziglio
fziglio at redhat.com
Tue Jul 30 12:02:54 UTC 2019
Initialise SpiceUsbBackendDevice fields earlier
Allows to use spice_usb_backend_device_unref and read some
information directly from the device.
---
src/usb-backend.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/src/usb-backend.c b/src/usb-backend.c
index 0b37274e..a447bbfe 100644
--- a/src/usb-backend.c
+++ b/src/usb-backend.c
@@ -920,19 +920,23 @@ gboolean spice_usb_backend_create_device(SpiceUsbBackend *be,
}
dev = g_new0(SpiceUsbBackendDevice, 1);
+ dev->device_info.bus = BUS_NUMBER_FOR_EMULATED_USB;
+ dev->device_info.address = address;
+ dev->device_info.device_type = dev_type;
+ dev->ref_count = 1;
param->address = address;
if (be->dev_init[dev_type](be, dev, param, &edev)) {
- g_free(dev);
+ spice_usb_backend_device_unref(dev);
return FALSE;
}
+ dev->edev = edev;
if (!device_ops(edev)->get_descriptor(edev, LIBUSB_DT_DEVICE, 0,
(void **)&desc, &device_desc_size)
|| device_desc_size != sizeof(*desc)) {
- device_ops(edev)->delete(edev);
- g_free(dev);
+ spice_usb_backend_device_unref(dev);
param->error = g_error_new(SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
_("can't create device - internal error"));
return FALSE;
@@ -940,17 +944,12 @@ gboolean spice_usb_backend_create_device(SpiceUsbBackend *be,
be->own_devices_mask |= 1 << address;
- dev->device_info.bus = BUS_NUMBER_FOR_EMULATED_USB;
- dev->device_info.address = address;
dev->device_info.vid = desc->idVendor;
dev->device_info.pid = desc->idProduct;
dev->device_info.bcdUSB = desc->bcdUSB;
dev->device_info.class = desc->bDeviceClass;
dev->device_info.subclass = desc->bDeviceSubClass;
dev->device_info.protocol = desc->bDeviceProtocol;
- dev->device_info.device_type = dev_type;
- dev->ref_count = 1;
- dev->edev = edev;
if (be->hotplug_callback) {
be->hotplug_callback(be->hotplug_user_data, dev, TRUE);
--
2.20.1
More information about the Spice-devel
mailing list