[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 05/19] uhci: QOMify
From: |
Gerd Hoffmann |
Subject: |
[Qemu-devel] [PULL 05/19] uhci: QOMify |
Date: |
Fri, 8 May 2015 13:45:39 +0200 |
From: Gonglei <address@hidden>
Cc: Gerd Hoffmann <address@hidden>
Signed-off-by: Gonglei <address@hidden>
Signed-off-by: Gerd Hoffmann <address@hidden>
---
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
- [Qemu-devel] [PULL 00/19] usb: qomify, bugfixes for xhci & uhci., Gerd Hoffmann, 2015/05/08
- [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
- [Qemu-devel] [PULL 07/19] usb: usb-bt QOMify, Gerd Hoffmann, 2015/05/08
- [Qemu-devel] [PULL 09/19] usb: usb-hub QOMify, Gerd Hoffmann, 2015/05/08
- [Qemu-devel] [PULL 19/19] uhci: controller is halted after reset, Gerd Hoffmann, 2015/05/08
- [Qemu-devel] [PULL 12/19] usb: usb-net QOMify, Gerd Hoffmann, 2015/05/08
- [Qemu-devel] [PULL 05/19] uhci: QOMify,
Gerd Hoffmann <=
- [Qemu-devel] [PULL 08/19] usb: usb-hid QOMify, Gerd Hoffmann, 2015/05/08
- [Qemu-devel] [PULL 04/19] xhci: fix events for setup trb., Gerd Hoffmann, 2015/05/08
- [Qemu-devel] [PULL 10/19] usb: usb-mtp QOMify, Gerd Hoffmann, 2015/05/08
- [Qemu-devel] [PULL 06/19] usb: usb-audio QOMify, Gerd Hoffmann, 2015/05/08
- [Qemu-devel] [PULL 02/19] xhci: set timer to retry xfers, Gerd Hoffmann, 2015/05/08
- [Qemu-devel] [PULL 01/19] usb: fix usb-net segfault, Gerd Hoffmann, 2015/05/08
- [Qemu-devel] [PULL 16/19] usb: usb-wacom-tablet QOMify, Gerd Hoffmann, 2015/05/08
- [Qemu-devel] [PULL 15/19] usb: usb-uas QOMify, Gerd Hoffmann, 2015/05/08
- [Qemu-devel] [PULL 14/19] usb: usb-storage QOMify, Gerd Hoffmann, 2015/05/08
- [Qemu-devel] [PULL 17/19] usb: usb-redir QOMify, Gerd Hoffmann, 2015/05/08