[Spice-devel] [spice-gtk v1 0/2] Add usb backend module

Christophe Fergeau cfergeau at redhat.com
Thu Sep 27 12:00:48 UTC 2018


Hey,

One additional high-level comment, after these patches, we have
in the public API an opaque SpiceUsbDevice, which is
// this is the structure behind SpiceUsbDevice
typedef struct _SpiceUsbDeviceInfo {
    guint8  busnum;
    guint8  devaddr;
    guint16 vid;
    guint16 pid;
    gboolean isochronous;
#ifdef G_OS_WIN32
    guint8  state;
#else
    SpiceUsbBackendDevice *bdev;
#endif
    gint    ref;
} SpiceUsbDeviceInfo;

SpiceUsbBackendDevice is
struct _SpiceUsbBackendDevice
{
    union
    {
        void *libusb_device;
        void *msc;
    } d;
    uint32_t isLibUsb   : 1;
    uint32_t configured : 1;                                                                             
    int refCount;
    void *mutex;
    SpiceUsbBackendChannel *attached_to;
    UsbDeviceInformation device_info;
};
And UsbDeviceInformation is
typedef struct UsbDeviceInformation
{
    uint16_t bus;
    uint16_t address;
    uint16_t vid;
    uint16_t pid;
    uint8_t class;
    uint8_t subclass;
    uint8_t protocol;
    uint8_t isochronous;
    uint8_t max_luns;
} UsbDeviceInformation;

This is really redundant, from experimenting a bit, it seems the
SpiceUsbBackendDevice + UsbDeviceInformation you add in this patch could
instead be SpiceUsbDevice. In short, I'd move SpiceUsbDeviceInfo
definition from usb-device-manager.c to a new usb-device.c (aka
usb-device-backend.c), and then add the new API introduced in your patch
on top of that, using SpiceUsbDevice everywhere rather than adding
SpiceUsbBackend.

Christophe
-------------- 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/20180927/85e9af63/attachment.sig>


More information about the Spice-devel mailing list