They were the same structure. Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx> --- src/usb-backend.c | 6 +++--- src/usb-backend.h | 6 +++--- src/usb-device-manager.c | 42 +++++++++++----------------------------- 3 files changed, 17 insertions(+), 37 deletions(-) diff --git a/src/usb-backend.c b/src/usb-backend.c index e61ec01f..cfd14e2c 100644 --- a/src/usb-backend.c +++ b/src/usb-backend.c @@ -44,7 +44,7 @@ #define LOUD_DEBUG(x, ...) -struct _SpiceUsbBackendDevice +struct _SpiceUsbDevice { libusb_device *libusb_device; gint ref_count; @@ -517,12 +517,12 @@ void spice_usb_backend_delete(SpiceUsbBackend *be) SPICE_DEBUG("%s <<", __FUNCTION__); } -const UsbDeviceInformation* spice_usb_backend_device_get_info(SpiceUsbBackendDevice *dev) +const UsbDeviceInformation* spice_usb_backend_device_get_info(const SpiceUsbBackendDevice *dev) { return &dev->device_info; } -gconstpointer spice_usb_backend_device_get_libdev(SpiceUsbBackendDevice *dev) +gconstpointer spice_usb_backend_device_get_libdev(const SpiceUsbBackendDevice *dev) { return dev->libusb_device; } diff --git a/src/usb-backend.h b/src/usb-backend.h index 66e13f54..5830312b 100644 --- a/src/usb-backend.h +++ b/src/usb-backend.h @@ -27,7 +27,7 @@ G_BEGIN_DECLS typedef struct _SpiceUsbBackend SpiceUsbBackend; -typedef struct _SpiceUsbBackendDevice SpiceUsbBackendDevice; +typedef struct _SpiceUsbDevice SpiceUsbBackendDevice; typedef struct _SpiceUsbBackendChannel SpiceUsbBackendChannel; typedef struct UsbDeviceInformation @@ -64,8 +64,8 @@ void spice_usb_backend_deregister_hotplug(SpiceUsbBackend *be); /* Spice USB backend device API */ SpiceUsbBackendDevice *spice_usb_backend_device_ref(SpiceUsbBackendDevice *dev); void spice_usb_backend_device_unref(SpiceUsbBackendDevice *dev); -gconstpointer spice_usb_backend_device_get_libdev(SpiceUsbBackendDevice *dev); -const UsbDeviceInformation* spice_usb_backend_device_get_info(SpiceUsbBackendDevice *dev); +gconstpointer spice_usb_backend_device_get_libdev(const SpiceUsbBackendDevice *dev); +const UsbDeviceInformation* spice_usb_backend_device_get_info(const SpiceUsbBackendDevice *dev); gboolean spice_usb_backend_device_isoch(SpiceUsbBackendDevice *dev); /* returns 0 if the device passes the filter */ int spice_usb_backend_device_check_filter(SpiceUsbBackendDevice *dev, diff --git a/src/usb-device-manager.c b/src/usb-device-manager.c index b85b20de..17bca099 100644 --- a/src/usb-device-manager.c +++ b/src/usb-device-manager.c @@ -120,12 +120,6 @@ enum { #ifdef USE_USBREDIR -struct _SpiceUsbDevice { - SpiceUsbBackendDevice *bdev; - gint ref; -}; - - static void channel_new(SpiceSession *session, SpiceChannel *channel, gpointer user_data); static void channel_destroy(SpiceSession *session, SpiceChannel *channel, @@ -637,7 +631,7 @@ spice_usb_device_get_libusb_device(const SpiceUsbDevice *info G_GNUC_UNUSED) #ifdef USE_USBREDIR g_return_val_if_fail(info != NULL, FALSE); - return spice_usb_backend_device_get_libdev(info->bdev); + return spice_usb_backend_device_get_libdev(info); #endif return NULL; } @@ -1480,16 +1474,9 @@ gchar *spice_usb_device_get_description(SpiceUsbDevice *device, const gchar *for */ static SpiceUsbDevice *spice_usb_device_new(SpiceUsbBackendDevice *bdev) { - SpiceUsbDevice *info; - g_return_val_if_fail(bdev != NULL, NULL); - info = g_new0(SpiceUsbDevice, 1); - - info->ref = 1; - info->bdev = spice_usb_backend_device_ref(bdev); - - return info; + return spice_usb_backend_device_ref(bdev); } guint16 spice_usb_device_get_busnum(const SpiceUsbDevice *info) @@ -1498,7 +1485,7 @@ guint16 spice_usb_device_get_busnum(const SpiceUsbDevice *info) g_return_val_if_fail(info != NULL, 0); - b_info = spice_usb_backend_device_get_info(info->bdev); + b_info = spice_usb_backend_device_get_info(info); return b_info->bus; } @@ -1508,7 +1495,7 @@ guint8 spice_usb_device_get_devaddr(const SpiceUsbDevice *info) g_return_val_if_fail(info != NULL, 0); - b_info = spice_usb_backend_device_get_info(info->bdev); + b_info = spice_usb_backend_device_get_info(info); return b_info->address; } @@ -1518,7 +1505,7 @@ guint16 spice_usb_device_get_vid(const SpiceUsbDevice *info) g_return_val_if_fail(info != NULL, 0); - b_info = spice_usb_backend_device_get_info(info->bdev); + b_info = spice_usb_backend_device_get_info(info); return b_info->vid; } @@ -1528,7 +1515,7 @@ guint16 spice_usb_device_get_pid(const SpiceUsbDevice *info) g_return_val_if_fail(info != NULL, 0); - b_info = spice_usb_backend_device_get_info(info->bdev); + b_info = spice_usb_backend_device_get_info(info); return b_info->pid; } @@ -1536,7 +1523,7 @@ gboolean spice_usb_device_is_isochronous(const SpiceUsbDevice *info) { g_return_val_if_fail(info != NULL, 0); - return spice_usb_backend_device_isoch(info->bdev); + return spice_usb_backend_device_isoch((SpiceUsbBackendDevice*) info); } #ifdef G_OS_WIN32 @@ -1615,21 +1602,14 @@ void _usbdk_hider_update(SpiceUsbDeviceManager *manager) static SpiceUsbDevice *spice_usb_device_ref(SpiceUsbDevice *info) { g_return_val_if_fail(info != NULL, NULL); - g_atomic_int_inc(&info->ref); - return info; + return spice_usb_backend_device_ref(info); } static void spice_usb_device_unref(SpiceUsbDevice *info) { - gboolean ref_count_is_0; - g_return_if_fail(info != NULL); - ref_count_is_0 = g_atomic_int_dec_and_test(&info->ref); - if (ref_count_is_0) { - spice_usb_backend_device_unref(info->bdev); - g_free(info); - } + spice_usb_backend_device_unref(info); } static gboolean @@ -1640,7 +1620,7 @@ spice_usb_manager_device_equal_bdev(SpiceUsbDeviceManager *manager, if ((info == NULL) || (bdev == NULL)) return FALSE; - return info->bdev == bdev; + return info == bdev; } /* @@ -1652,6 +1632,6 @@ spice_usb_device_manager_device_to_bdev(SpiceUsbDeviceManager *self, SpiceUsbDevice *info) { /* Simply return a ref to the cached libdev */ - return spice_usb_backend_device_ref(info->bdev); + return spice_usb_backend_device_ref(info); } #endif /* USE_USBREDIR */ -- 2.20.1 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel