From patchwork Wed Feb 1 19:50:43 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony Liguori X-Patchwork-Id: 138978 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id E6CFDB6EEA for ; Thu, 2 Feb 2012 06:51:37 +1100 (EST) Received: from localhost ([::1]:53330 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RsgDN-0007sp-0w for incoming@patchwork.ozlabs.org; Wed, 01 Feb 2012 14:51:33 -0500 Received: from eggs.gnu.org ([140.186.70.92]:37364) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RsgDE-0007oL-Ar for qemu-devel@nongnu.org; Wed, 01 Feb 2012 14:51:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RsgDC-0005x4-DZ for qemu-devel@nongnu.org; Wed, 01 Feb 2012 14:51:24 -0500 Received: from cpe-70-123-132-139.austin.res.rr.com ([70.123.132.139]:52850 helo=localhost6.localdomain6) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RsgDC-0005wk-5Y for qemu-devel@nongnu.org; Wed, 01 Feb 2012 14:51:22 -0500 Received: from localhost6.localdomain6 (localhost.localdomain [127.0.0.1]) by localhost6.localdomain6 (8.14.4/8.14.4/Debian-2ubuntu1) with ESMTP id q11JpHUr006319; Wed, 1 Feb 2012 13:51:17 -0600 Received: (from anthony@localhost) by localhost6.localdomain6 (8.14.4/8.14.4/Submit) id q11JpFER006318; Wed, 1 Feb 2012 13:51:15 -0600 From: Anthony Liguori To: qemu-devel@nongnu.org Date: Wed, 1 Feb 2012 13:50:43 -0600 Message-Id: <1328125863-6203-3-git-send-email-aliguori@us.ibm.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1328125863-6203-1-git-send-email-aliguori@us.ibm.com> References: <1328125863-6203-1-git-send-email-aliguori@us.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 70.123.132.139 Cc: Paolo Bonzini , Anthony Liguori , Andreas Faerber , Peter Maydell Subject: [Qemu-devel] [PATCH 02/22] usb: separate out legacy usb registration from type registration X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Type registeration is going to get turned into a QOM call so decouple the legacy support. Signed-off-by: Anthony Liguori --- 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 --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)