usb: Allow overriding of usb_desc at the device level
authorHans de Goede <hdegoede@redhat.com>
Sat, 17 Nov 2012 11:47:16 +0000 (12:47 +0100)
committerGerd Hoffmann <kraxel@redhat.com>
Tue, 4 Dec 2012 13:41:54 +0000 (14:41 +0100)
This allows devices to present a different set of descriptors based on
device properties.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
hw/usb.h
hw/usb/bus.c

index 58f812f7d013456179f3f2c5c93e32ed1beec8d4..268e6539aa65fdf4cc06c7606c575986d5a8e010 100644 (file)
--- a/hw/usb.h
+++ b/hw/usb.h
@@ -230,6 +230,7 @@ struct USBDevice {
     USBEndpoint ep_out[USB_MAX_ENDPOINTS];
 
     QLIST_HEAD(, USBDescString) strings;
+    const USBDesc *usb_desc; /* Overrides class usb_desc if not NULL */
     const USBDescDevice *device;
 
     int configuration;
index 55d0edd5c347797836b7681b592470b4bcf3cd01..8264c240ee6cfd4b3de7eb97b17ae4575ecfdbb9 100644 (file)
@@ -166,6 +166,9 @@ const char *usb_device_get_product_desc(USBDevice *dev)
 const USBDesc *usb_device_get_usb_desc(USBDevice *dev)
 {
     USBDeviceClass *klass = USB_DEVICE_GET_CLASS(dev);
+    if (dev->usb_desc) {
+        return dev->usb_desc;
+    }
     return klass->usb_desc;
 }