Patchwork [FOR,0.12,v2,2/3] qdev: Separate USB product description from qdev name

login
register
mail settings
Submitter Markus Armbruster
Date Dec. 9, 2009, 4:07 p.m.
Message ID <1260374873-29783-3-git-send-email-armbru@redhat.com>
Download mbox | patch
Permalink /patch/40732/
State New
Headers show

Comments

Markus Armbruster - Dec. 9, 2009, 4:07 p.m.
Using the qdev name for the product description makes for inconvenient
qdev names.

Put the product description in new USBDeviceInfo member product_desc.
Make usb_qdev_init() use it.  No user or guest visible change, since
the value is still the same.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/usb-bt.c     |    1 +
 hw/usb-bus.c    |    2 +-
 hw/usb-hid.c    |    3 +++
 hw/usb-hub.c    |    1 +
 hw/usb-msd.c    |    1 +
 hw/usb-net.c    |    1 +
 hw/usb-serial.c |    2 ++
 hw/usb-wacom.c  |    1 +
 hw/usb.h        |    2 ++
 usb-bsd.c       |    1 +
 usb-linux.c     |    1 +
 11 files changed, 15 insertions(+), 1 deletions(-)

Patch

diff --git a/hw/usb-bt.c b/hw/usb-bt.c
index 18d7a98..07da133 100644
--- a/hw/usb-bt.c
+++ b/hw/usb-bt.c
@@ -645,6 +645,7 @@  USBDevice *usb_bt_init(HCIInfo *hci)
 }
 
 static struct USBDeviceInfo bt_info = {
+    .product_desc   = "QEMU BT dongle",
     .qdev.name      = "QEMU BT dongle",
     .qdev.size      = sizeof(struct USBBtState),
     .init           = usb_bt_initfn,
diff --git a/hw/usb-bus.c b/hw/usb-bus.c
index ba1b6e3..8bbc80d 100644
--- a/hw/usb-bus.c
+++ b/hw/usb-bus.c
@@ -43,7 +43,7 @@  static int usb_qdev_init(DeviceState *qdev, DeviceInfo *base)
     USBDeviceInfo *info = DO_UPCAST(USBDeviceInfo, qdev, base);
     int rc;
 
-    pstrcpy(dev->product_desc, sizeof(dev->product_desc), qdev->info->name);
+    pstrcpy(dev->product_desc, sizeof(dev->product_desc), info->product_desc);
     dev->info = info;
     dev->auto_attach = 1;
     rc = dev->info->init(dev);
diff --git a/hw/usb-hid.c b/hw/usb-hid.c
index 6621f72..33de302 100644
--- a/hw/usb-hid.c
+++ b/hw/usb-hid.c
@@ -880,6 +880,7 @@  void usb_hid_datain_cb(USBDevice *dev, void *opaque, void (*datain)(void *))
 
 static struct USBDeviceInfo hid_info[] = {
     {
+        .product_desc   = "QEMU USB Tablet",
         .qdev.name      = "QEMU USB Tablet",
         .qdev.alias     = "usb-tablet",
         .usbdevice_name = "tablet",
@@ -891,6 +892,7 @@  static struct USBDeviceInfo hid_info[] = {
         .handle_data    = usb_hid_handle_data,
         .handle_destroy = usb_hid_handle_destroy,
     },{
+        .product_desc   = "QEMU USB Mouse",
         .qdev.name      = "QEMU USB Mouse",
         .qdev.alias     = "usb-mouse",
         .usbdevice_name = "mouse",
@@ -902,6 +904,7 @@  static struct USBDeviceInfo hid_info[] = {
         .handle_data    = usb_hid_handle_data,
         .handle_destroy = usb_hid_handle_destroy,
     },{
+        .product_desc   = "QEMU USB Keyboard",
         .qdev.name      = "QEMU USB Keyboard",
         .qdev.alias     = "usb-kbd",
         .usbdevice_name = "keyboard",
diff --git a/hw/usb-hub.c b/hw/usb-hub.c
index e5a0938..32f2ab8 100644
--- a/hw/usb-hub.c
+++ b/hw/usb-hub.c
@@ -544,6 +544,7 @@  static int usb_hub_initfn(USBDevice *dev)
 }
 
 static struct USBDeviceInfo hub_info = {
+    .product_desc   = "QEMU USB Hub",
     .qdev.name      = "QEMU USB Hub",
     .qdev.size      = sizeof(USBHubState),
     .init           = usb_hub_initfn,
diff --git a/hw/usb-msd.c b/hw/usb-msd.c
index bb39b62..b9f6588 100644
--- a/hw/usb-msd.c
+++ b/hw/usb-msd.c
@@ -600,6 +600,7 @@  static USBDevice *usb_msd_init(const char *filename)
 }
 
 static struct USBDeviceInfo msd_info = {
+    .product_desc   = "QEMU USB MSD",
     .qdev.name      = "QEMU USB MSD",
     .qdev.alias     = "usb-storage",
     .qdev.size      = sizeof(MSDState),
diff --git a/hw/usb-net.c b/hw/usb-net.c
index 2556e05..3dd05e3 100644
--- a/hw/usb-net.c
+++ b/hw/usb-net.c
@@ -1487,6 +1487,7 @@  USBDevice *usb_net_init(NICInfo *nd)
 }
 
 static struct USBDeviceInfo net_info = {
+    .product_desc   = "QEMU USB Network Interface",
     .qdev.name      = "QEMU USB Network Interface",
     .qdev.size      = sizeof(USBNetState),
     .init           = usb_net_initfn,
diff --git a/hw/usb-serial.c b/hw/usb-serial.c
index 223d4c3..14e410e 100644
--- a/hw/usb-serial.c
+++ b/hw/usb-serial.c
@@ -605,6 +605,7 @@  static USBDevice *usb_braille_init(const char *unused)
 }
 
 static struct USBDeviceInfo serial_info = {
+    .product_desc   = "QEMU USB Serial",
     .qdev.name      = "QEMU USB Serial",
     .qdev.alias     = "usb-serial",
     .qdev.size      = sizeof(USBSerialState),
@@ -625,6 +626,7 @@  static struct USBDeviceInfo serial_info = {
 };
 
 static struct USBDeviceInfo braille_info = {
+    .product_desc   = "QEMU USB Braille",
     .qdev.name      = "QEMU USB Braille",
     .qdev.alias     = "usb-braille",
     .qdev.size      = sizeof(USBSerialState),
diff --git a/hw/usb-wacom.c b/hw/usb-wacom.c
index ef61376..b10864f 100644
--- a/hw/usb-wacom.c
+++ b/hw/usb-wacom.c
@@ -409,6 +409,7 @@  static int usb_wacom_initfn(USBDevice *dev)
 }
 
 static struct USBDeviceInfo wacom_info = {
+    .product_desc   = "QEMU PenPartner Tablet",
     .qdev.name      = "QEMU PenPartner Tablet",
     .qdev.alias     = "wacom-tablet",
     .usbdevice_name = "wacom-tablet",
diff --git a/hw/usb.h b/hw/usb.h
index 39aba99..0684588 100644
--- a/hw/usb.h
+++ b/hw/usb.h
@@ -185,6 +185,8 @@  struct USBDeviceInfo {
      */
     int (*handle_data)(USBDevice *dev, USBPacket *p);
 
+    const char *product_desc;
+
     /* handle legacy -usbdevice command line options */
     const char *usbdevice_name;
     USBDevice *(*usbdevice_init)(const char *params);
diff --git a/usb-bsd.c b/usb-bsd.c
index a9987d1..e72d123 100644
--- a/usb-bsd.c
+++ b/usb-bsd.c
@@ -393,6 +393,7 @@  fail:
 }
 
 static struct USBDeviceInfo usb_host_dev_info = {
+    .product_desc   = "USB Host Device",
     .qdev.name      = "USB Host Device",
     .qdev.size      = sizeof(USBHostDevice),
     .init           = usb_host_initfn,
diff --git a/usb-linux.c b/usb-linux.c
index 67735d3..0004e96 100644
--- a/usb-linux.c
+++ b/usb-linux.c
@@ -979,6 +979,7 @@  static int usb_host_initfn(USBDevice *dev)
 }
 
 static struct USBDeviceInfo usb_host_dev_info = {
+    .product_desc   = "USB Host Device",
     .qdev.name      = "USB Host Device",
     .qdev.alias     = "usb-host",
     .qdev.size      = sizeof(USBHostDevice),