Patchwork [2/5] usb-hid: use qdev for -usbdevice

login
register
mail settings
Submitter Gerd Hoffmann
Date Oct. 23, 2009, 9:26 a.m.
Message ID <1256289963-26430-3-git-send-email-kraxel@redhat.com>
Download mbox | patch
Permalink /patch/36770/
State New
Headers show

Comments

Gerd Hoffmann - Oct. 23, 2009, 9:26 a.m.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/usb-hid.c   |    3 +++
 hw/usb-wacom.c |    1 +
 vl.c           |   29 -----------------------------
 3 files changed, 4 insertions(+), 29 deletions(-)

Patch

diff --git a/hw/usb-hid.c b/hw/usb-hid.c
index d1cc45e..f4a2a48 100644
--- a/hw/usb-hid.c
+++ b/hw/usb-hid.c
@@ -882,6 +882,7 @@  static struct USBDeviceInfo hid_info[] = {
     {
         .qdev.name      = "QEMU USB Tablet",
         .qdev.alias     = "usb-tablet",
+        .usbdevice_name = "tablet",
         .qdev.size      = sizeof(USBHIDState),
         .init           = usb_tablet_initfn,
         .handle_packet  = usb_generic_handle_packet,
@@ -892,6 +893,7 @@  static struct USBDeviceInfo hid_info[] = {
     },{
         .qdev.name      = "QEMU USB Mouse",
         .qdev.alias     = "usb-mouse",
+        .usbdevice_name = "mouse",
         .qdev.size      = sizeof(USBHIDState),
         .init           = usb_mouse_initfn,
         .handle_packet  = usb_generic_handle_packet,
@@ -902,6 +904,7 @@  static struct USBDeviceInfo hid_info[] = {
     },{
         .qdev.name      = "QEMU USB Keyboard",
         .qdev.alias     = "usb-kbd",
+        .usbdevice_name = "keyboard",
         .qdev.size      = sizeof(USBHIDState),
         .init           = usb_keyboard_initfn,
         .handle_packet  = usb_generic_handle_packet,
diff --git a/hw/usb-wacom.c b/hw/usb-wacom.c
index fa97db2..ef61376 100644
--- a/hw/usb-wacom.c
+++ b/hw/usb-wacom.c
@@ -411,6 +411,7 @@  static int usb_wacom_initfn(USBDevice *dev)
 static struct USBDeviceInfo wacom_info = {
     .qdev.name      = "QEMU PenPartner Tablet",
     .qdev.alias     = "wacom-tablet",
+    .usbdevice_name = "wacom-tablet",
     .qdev.size      = sizeof(USBWacomState),
     .init           = usb_wacom_initfn,
     .handle_packet  = usb_generic_handle_packet,
diff --git a/vl.c b/vl.c
index 30b5306..52ab14f 100644
--- a/vl.c
+++ b/vl.c
@@ -2533,31 +2533,10 @@  static void usb_msd_password_cb(void *opaque, int err)
         dev->info->handle_destroy(dev);
 }
 
-static struct {
-    const char *name;
-    const char *qdev;
-} usbdevs[] = {
-    {
-        .name = "mouse",
-        .qdev = "QEMU USB Mouse",
-    },{
-        .name = "tablet",
-        .qdev = "QEMU USB Tablet",
-    },{
-        .name = "keyboard",
-        .qdev = "QEMU USB Keyboard",
-    },{
-        .name = "wacom-tablet",
-        .qdev = "QEMU PenPartner Tablet",
-    }
-};
-
 static int usb_device_add(const char *devname, int is_hotplug)
 {
     const char *p;
-    USBBus *bus = usb_bus_find(-1 /* any */);
     USBDevice *dev = NULL;
-    int i;
 
     if (!usb_enabled)
         return -1;
@@ -2567,14 +2546,6 @@  static int usb_device_add(const char *devname, int is_hotplug)
     if (dev)
         goto done;
 
-    /* simple devices which don't need extra care */
-    for (i = 0; i < ARRAY_SIZE(usbdevs); i++) {
-        if (strcmp(devname, usbdevs[i].name) != 0)
-            continue;
-        dev = usb_create_simple(bus, usbdevs[i].qdev);
-        goto done;
-    }
-
     /* the other ones */
     if (strstart(devname, "host:", &p)) {
         dev = usb_host_device_open(p);