qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gonglei <arei.gonglei@huawei.com>, Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PULL 05/19] uhci: QOMify
Date: Fri,  8 May 2015 13:45:39 +0200	[thread overview]
Message-ID: <1431085553-6055-6-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1431085553-6055-1-git-send-email-kraxel@redhat.com>

From: Gonglei <arei.gonglei@huawei.com>

Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/usb/hcd-uhci.c | 43 +++++++++++++++++++++++++++++++------------
 1 file changed, 31 insertions(+), 12 deletions(-)

diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c
index 327f26d..64a7d87 100644
--- a/hw/usb/hcd-uhci.c
+++ b/hw/usb/hcd-uhci.c
@@ -154,6 +154,9 @@ static void uhci_async_cancel(UHCIAsync *async);
 static void uhci_queue_fill(UHCIQueue *q, UHCI_TD *td);
 static void uhci_resume(void *opaque);
 
+#define TYPE_UHCI "pci-uhci-usb"
+#define UHCI(obj) OBJECT_CHECK(UHCIState, (obj), TYPE_UHCI)
+
 static inline int32_t uhci_queue_token(UHCI_TD *td)
 {
     if ((td->token & (0xf << 15)) == 0) {
@@ -351,7 +354,7 @@ static void uhci_update_irq(UHCIState *s)
 static void uhci_reset(DeviceState *dev)
 {
     PCIDevice *d = PCI_DEVICE(dev);
-    UHCIState *s = DO_UPCAST(UHCIState, dev, d);
+    UHCIState *s = UHCI(d);
     uint8_t *pci_conf;
     int i;
     UHCIPort *port;
@@ -1196,7 +1199,7 @@ static void usb_uhci_common_realize(PCIDevice *dev, Error **errp)
     Error *err = NULL;
     PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(dev);
     UHCIPCIDeviceClass *u = container_of(pc, UHCIPCIDeviceClass, parent_class);
-    UHCIState *s = DO_UPCAST(UHCIState, dev, dev);
+    UHCIState *s = UHCI(dev);
     uint8_t *pci_conf = s->dev.config;
     int i;
 
@@ -1241,7 +1244,7 @@ static void usb_uhci_common_realize(PCIDevice *dev, Error **errp)
 
 static void usb_uhci_vt82c686b_realize(PCIDevice *dev, Error **errp)
 {
-    UHCIState *s = DO_UPCAST(UHCIState, dev, dev);
+    UHCIState *s = UHCI(dev);
     uint8_t *pci_conf = s->dev.config;
 
     /* USB misc control 1/2 */
@@ -1256,7 +1259,7 @@ static void usb_uhci_vt82c686b_realize(PCIDevice *dev, Error **errp)
 
 static void usb_uhci_exit(PCIDevice *dev)
 {
-    UHCIState *s = DO_UPCAST(UHCIState, dev, dev);
+    UHCIState *s = UHCI(dev);
 
     trace_usb_uhci_exit();
 
@@ -1294,6 +1297,26 @@ static void uhci_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
     PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
+
+    k->class_id  = PCI_CLASS_SERIAL_USB;
+    dc->vmsd = &vmstate_uhci;
+    dc->reset = uhci_reset;
+    set_bit(DEVICE_CATEGORY_USB, dc->categories);
+}
+
+static const TypeInfo uhci_pci_type_info = {
+    .name = TYPE_UHCI,
+    .parent = TYPE_PCI_DEVICE,
+    .instance_size = sizeof(UHCIState),
+    .class_size    = sizeof(UHCIPCIDeviceClass),
+    .abstract = true,
+    .class_init = uhci_class_init,
+};
+
+static void uhci_data_class_init(ObjectClass *klass, void *data)
+{
+    PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
+    DeviceClass *dc = DEVICE_CLASS(klass);
     UHCIPCIDeviceClass *u = container_of(k, UHCIPCIDeviceClass, parent_class);
     UHCIInfo *info = data;
 
@@ -1302,9 +1325,6 @@ static void uhci_class_init(ObjectClass *klass, void *data)
     k->vendor_id = info->vendor_id;
     k->device_id = info->device_id;
     k->revision  = info->revision;
-    k->class_id  = PCI_CLASS_SERIAL_USB;
-    dc->vmsd = &vmstate_uhci;
-    dc->reset = uhci_reset;
     if (!info->unplug) {
         /* uhci controllers in companion setups can't be hotplugged */
         dc->hotpluggable = false;
@@ -1312,7 +1332,6 @@ static void uhci_class_init(ObjectClass *klass, void *data)
     } else {
         dc->props = uhci_properties_standalone;
     }
-    set_bit(DEVICE_CATEGORY_USB, dc->categories);
     u->info = *info;
 }
 
@@ -1387,13 +1406,13 @@ static UHCIInfo uhci_info[] = {
 static void uhci_register_types(void)
 {
     TypeInfo uhci_type_info = {
-        .parent        = TYPE_PCI_DEVICE,
-        .instance_size = sizeof(UHCIState),
-        .class_size    = sizeof(UHCIPCIDeviceClass),
-        .class_init    = uhci_class_init,
+        .parent        = TYPE_UHCI,
+        .class_init    = uhci_data_class_init,
     };
     int i;
 
+    type_register_static(&uhci_pci_type_info);
+
     for (i = 0; i < ARRAY_SIZE(uhci_info); i++) {
         uhci_type_info.name = uhci_info[i].name;
         uhci_type_info.class_data = uhci_info + i;
-- 
1.8.3.1

  parent reply	other threads:[~2015-05-08 11:46 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-08 11:45 [Qemu-devel] [PULL 00/19] usb: qomify, bugfixes for xhci & uhci Gerd Hoffmann
2015-05-08 11:45 ` [Qemu-devel] [PULL 01/19] usb: fix usb-net segfault Gerd Hoffmann
2015-05-08 11:45 ` [Qemu-devel] [PULL 02/19] xhci: set timer to retry xfers Gerd Hoffmann
2015-05-08 11:45 ` [Qemu-devel] [PULL 03/19] Revert "xhci: generate a Transfer Event for each Transfer TRB with the IOC bit set" Gerd Hoffmann
2015-05-08 11:45 ` [Qemu-devel] [PULL 04/19] xhci: fix events for setup trb Gerd Hoffmann
2015-05-08 11:45 ` Gerd Hoffmann [this message]
2015-05-08 11:45 ` [Qemu-devel] [PULL 06/19] usb: usb-audio QOMify Gerd Hoffmann
2015-05-08 11:45 ` [Qemu-devel] [PULL 07/19] usb: usb-bt QOMify Gerd Hoffmann
2015-05-08 11:45 ` [Qemu-devel] [PULL 08/19] usb: usb-hid QOMify Gerd Hoffmann
2015-05-08 11:45 ` [Qemu-devel] [PULL 09/19] usb: usb-hub QOMify Gerd Hoffmann
2015-05-08 11:45 ` [Qemu-devel] [PULL 10/19] usb: usb-mtp QOMify Gerd Hoffmann
2015-05-08 11:45 ` [Qemu-devel] [PULL 11/19] usb-mtp: fix segmentation fault Gerd Hoffmann
2015-05-08 11:45 ` [Qemu-devel] [PULL 12/19] usb: usb-net QOMify Gerd Hoffmann
2015-05-08 11:45 ` [Qemu-devel] [PULL 13/19] usb: usb-ccid QOMify Gerd Hoffmann
2015-05-08 11:45 ` [Qemu-devel] [PULL 14/19] usb: usb-storage QOMify Gerd Hoffmann
2015-05-08 11:45 ` [Qemu-devel] [PULL 15/19] usb: usb-uas QOMify Gerd Hoffmann
2015-05-08 11:45 ` [Qemu-devel] [PULL 16/19] usb: usb-wacom-tablet QOMify Gerd Hoffmann
2015-05-08 11:45 ` [Qemu-devel] [PULL 17/19] usb: usb-redir QOMify Gerd Hoffmann
2015-05-08 11:45 ` [Qemu-devel] [PULL 18/19] usb: usb-serial QOMify Gerd Hoffmann
2015-05-10 22:18   ` Samuel Thibault
2015-05-08 11:45 ` [Qemu-devel] [PULL 19/19] uhci: controller is halted after reset Gerd Hoffmann
2015-05-11  9:42 ` [Qemu-devel] [PULL 00/19] usb: qomify, bugfixes for xhci & uhci Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1431085553-6055-6-git-send-email-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=arei.gonglei@huawei.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).