diff mbox

[02/22] usb: separate out legacy usb registration from type registration

Message ID 1328125863-6203-3-git-send-email-aliguori@us.ibm.com
State New
Headers show

Commit Message

Anthony Liguori Feb. 1, 2012, 7:50 p.m. UTC
Type registeration is going to get turned into a QOM call so decouple the
legacy support.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
 hw/usb-audio.c  |    3 ++-
 hw/usb-bt.c     |    2 +-
 hw/usb-bus.c    |   22 ++++++++++++----------
 hw/usb-ccid.c   |    3 ++-
 hw/usb-hid.c    |    9 ++++++---
 hw/usb-hub.c    |    2 +-
 hw/usb-msd.c    |    3 ++-
 hw/usb-net.c    |    3 ++-
 hw/usb-serial.c |    6 ++++--
 hw/usb-wacom.c  |    3 ++-
 hw/usb.h        |    6 +++---
 usb-linux.c     |    3 ++-
 12 files changed, 39 insertions(+), 26 deletions(-)
diff mbox

Patch

diff --git a/hw/usb-audio.c b/hw/usb-audio.c
index 561ae31..459f162 100644
--- a/hw/usb-audio.c
+++ b/hw/usb-audio.c
@@ -704,7 +704,8 @@  static struct DeviceInfo usb_audio_info = {
 
 static void usb_audio_register_devices(void)
 {
-    usb_qdev_register(&usb_audio_info, "audio", NULL);
+    usb_qdev_register(&usb_audio_info);
+    usb_legacy_register("usb-audio", "audio", NULL);
 }
 
 device_init(usb_audio_register_devices)
diff --git a/hw/usb-bt.c b/hw/usb-bt.c
index bf8c470..f497a44 100644
--- a/hw/usb-bt.c
+++ b/hw/usb-bt.c
@@ -550,6 +550,6 @@  static struct DeviceInfo bt_info = {
 
 static void usb_bt_register_devices(void)
 {
-    usb_qdev_register(&bt_info, NULL, NULL);
+    usb_qdev_register(&bt_info);
 }
 device_init(usb_bt_register_devices)
diff --git a/hw/usb-bus.c b/hw/usb-bus.c
index aeef908..6b0adfd 100644
--- a/hw/usb-bus.c
+++ b/hw/usb-bus.c
@@ -208,25 +208,27 @@  typedef struct LegacyUSBFactory
 
 static GSList *legacy_usb_factory;
 
-void usb_qdev_register(DeviceInfo *info,
-                       const char *usbdevice_name,
-                       USBDevice *(*usbdevice_init)(const char *params))
+void usb_legacy_register(const char *typename, const char *usbdevice_name,
+                         USBDevice *(*usbdevice_init)(const char *params))
 {
-    info->bus_info = &usb_bus_info;
-    info->init     = usb_qdev_init;
-    info->unplug   = qdev_simple_unplug_cb;
-    info->exit     = usb_qdev_exit;
-    qdev_register_subclass(info, TYPE_USB_DEVICE);
-
     if (usbdevice_name) {
         LegacyUSBFactory *f = g_malloc0(sizeof(*f));
-        f->name = info->name;
+        f->name = typename;
         f->usbdevice_name = usbdevice_name;
         f->usbdevice_init = usbdevice_init;
         legacy_usb_factory = g_slist_append(legacy_usb_factory, f);
     }
 }
 
+void usb_qdev_register(DeviceInfo *info)
+{
+    info->bus_info = &usb_bus_info;
+    info->init     = usb_qdev_init;
+    info->unplug   = qdev_simple_unplug_cb;
+    info->exit     = usb_qdev_exit;
+    qdev_register_subclass(info, TYPE_USB_DEVICE);
+}
+
 USBDevice *usb_create(USBBus *bus, const char *name)
 {
     DeviceState *dev;
diff --git a/hw/usb-ccid.c b/hw/usb-ccid.c
index aff81fa..a261d7d 100644
--- a/hw/usb-ccid.c
+++ b/hw/usb-ccid.c
@@ -1352,6 +1352,7 @@  static TypeInfo ccid_card_type_info = {
 static void ccid_register_devices(void)
 {
     type_register_static(&ccid_card_type_info);
-    usb_qdev_register(&ccid_info, "ccid", NULL);
+    usb_qdev_register(&ccid_info);
+    usb_legacy_register(CCID_DEV_NAME, "ccid", NULL);
 }
 device_init(ccid_register_devices)
diff --git a/hw/usb-hid.c b/hw/usb-hid.c
index 4af27a2..669aae4 100644
--- a/hw/usb-hid.c
+++ b/hw/usb-hid.c
@@ -617,8 +617,11 @@  static struct DeviceInfo usb_keyboard_info = {
 
 static void usb_hid_register_devices(void)
 {
-    usb_qdev_register(&usb_tablet_info, "tablet", NULL);
-    usb_qdev_register(&usb_mouse_info, "mouse", NULL);
-    usb_qdev_register(&usb_keyboard_info, "keyboard", NULL);
+    usb_qdev_register(&usb_tablet_info);
+    usb_legacy_register("usb-tablet", "tablet", NULL);
+    usb_qdev_register(&usb_mouse_info);
+    usb_legacy_register("usb-mouse", "mouse", NULL);
+    usb_qdev_register(&usb_keyboard_info);
+    usb_legacy_register("usb-kbd", "keyboard", NULL);
 }
 device_init(usb_hid_register_devices)
diff --git a/hw/usb-hub.c b/hw/usb-hub.c
index ee4e6a6..3e33685 100644
--- a/hw/usb-hub.c
+++ b/hw/usb-hub.c
@@ -557,6 +557,6 @@  static struct DeviceInfo hub_info = {
 
 static void usb_hub_register_devices(void)
 {
-    usb_qdev_register(&hub_info, NULL, NULL);
+    usb_qdev_register(&hub_info);
 }
 device_init(usb_hub_register_devices)
diff --git a/hw/usb-msd.c b/hw/usb-msd.c
index ceb01e0..19d0d7b 100644
--- a/hw/usb-msd.c
+++ b/hw/usb-msd.c
@@ -667,6 +667,7 @@  static struct DeviceInfo msd_info = {
 
 static void usb_msd_register_devices(void)
 {
-    usb_qdev_register(&msd_info, "disk", usb_msd_init);
+    usb_qdev_register(&msd_info);
+    usb_legacy_register("usb-storage", "disk", usb_msd_init);
 }
 device_init(usb_msd_register_devices)
diff --git a/hw/usb-net.c b/hw/usb-net.c
index 57b58ac..65eee95 100644
--- a/hw/usb-net.c
+++ b/hw/usb-net.c
@@ -1413,6 +1413,7 @@  static struct DeviceInfo net_info = {
 
 static void usb_net_register_devices(void)
 {
-    usb_qdev_register(&net_info, "net", usb_net_init);
+    usb_qdev_register(&net_info);
+    usb_legacy_register("usb-net", "net", usb_net_init);
 }
 device_init(usb_net_register_devices)
diff --git a/hw/usb-serial.c b/hw/usb-serial.c
index de49607..00b4985 100644
--- a/hw/usb-serial.c
+++ b/hw/usb-serial.c
@@ -622,7 +622,9 @@  static struct DeviceInfo braille_info = {
 
 static void usb_serial_register_devices(void)
 {
-    usb_qdev_register(&serial_info, "serial", usb_serial_init);
-    usb_qdev_register(&braille_info, "braille", usb_braille_init);
+    usb_qdev_register(&serial_info);
+    usb_legacy_register("usb-serial", "serial", usb_serial_init);
+    usb_qdev_register(&braille_info);
+    usb_legacy_register("usb-braille", "braille", usb_braille_init);
 }
 device_init(usb_serial_register_devices)
diff --git a/hw/usb-wacom.c b/hw/usb-wacom.c
index 9b20a31..40bb199 100644
--- a/hw/usb-wacom.c
+++ b/hw/usb-wacom.c
@@ -373,6 +373,7 @@  static struct DeviceInfo wacom_info = {
 
 static void usb_wacom_register_devices(void)
 {
-    usb_qdev_register(&wacom_info, "wacom-tablet", NULL);
+    usb_qdev_register(&wacom_info);
+    usb_legacy_register("usb-wacom-tablet", "wacom-tablet", NULL);
 }
 device_init(usb_wacom_register_devices)
diff --git a/hw/usb.h b/hw/usb.h
index 5b9badb..b9b6742 100644
--- a/hw/usb.h
+++ b/hw/usb.h
@@ -418,9 +418,9 @@  struct USBBusOps {
 
 void usb_bus_new(USBBus *bus, USBBusOps *ops, DeviceState *host);
 USBBus *usb_bus_find(int busnr);
-void usb_qdev_register(DeviceInfo *info,
-                       const char *usbdevice_name,
-                       USBDevice *(*usbdevice_init)(const char *params));
+void usb_qdev_register(DeviceInfo *info);
+void usb_legacy_register(const char *typename, const char *usbdevice_name,
+                         USBDevice *(*usbdevice_init)(const char *params));
 USBDevice *usb_create(USBBus *bus, const char *name);
 USBDevice *usb_create_simple(USBBus *bus, const char *name);
 USBDevice *usbdevice_create(const char *cmdline);
diff --git a/usb-linux.c b/usb-linux.c
index 31810f6..a337db5 100644
--- a/usb-linux.c
+++ b/usb-linux.c
@@ -1434,7 +1434,8 @@  static struct DeviceInfo usb_host_dev_info = {
 
 static void usb_host_register_devices(void)
 {
-    usb_qdev_register(&usb_host_dev_info, "host", usb_host_device_open);
+    usb_qdev_register(&usb_host_dev_info);
+    usb_legacy_register("usb-host", "host", usb_host_device_open);
 }
 device_init(usb_host_register_devices)