From 5aa3ca9f53cc7a1bf76b7583c46937a73914394a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Sun, 16 Dec 2012 04:49:43 +0100 Subject: usb/ehci: Clean up SysBus and PCI EHCI split MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SysBus EHCI was introduced in a hurry before 1.3 Soft Freeze. To use QOM casts in place of DO_UPCAST() / FROM_SYSBUS(), we need an identifying type. Introduce generic abstract base types for PCI and SysBus EHCI to allow multiple types to access the shared fields. While at it, move the state structs being amended with macros to the header file so that they can be embedded. The VMSTATE_PCI_DEVICE() macro does not play nice with the QOM parent_obj naming convention, so defer that cleanup. Signed-off-by: Andreas Färber Signed-off-by: Gerd Hoffmann --- hw/usb/hcd-ehci-sysbus.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'hw/usb/hcd-ehci-sysbus.c') diff --git a/hw/usb/hcd-ehci-sysbus.c b/hw/usb/hcd-ehci-sysbus.c index 803df92f31..d4311936ba 100644 --- a/hw/usb/hcd-ehci-sysbus.c +++ b/hw/usb/hcd-ehci-sysbus.c @@ -16,12 +16,6 @@ */ #include "hw/usb/hcd-ehci.h" -#include "hw/sysbus.h" - -typedef struct EHCISysBusState { - SysBusDevice busdev; - EHCIState ehci; -} EHCISysBusState; static const VMStateDescription vmstate_ehci_sysbus = { .name = "ehci-sysbus", @@ -40,7 +34,7 @@ static Property ehci_sysbus_properties[] = { static int usb_ehci_sysbus_initfn(SysBusDevice *dev) { - EHCISysBusState *i = FROM_SYSBUS(EHCISysBusState, dev); + EHCISysBusState *i = SYS_BUS_EHCI(dev); EHCIState *s = &i->ehci; s->capsbase = 0x100; @@ -63,15 +57,22 @@ static void ehci_sysbus_class_init(ObjectClass *klass, void *data) dc->props = ehci_sysbus_properties; } -TypeInfo ehci_xlnx_type_info = { - .name = "xlnx,ps7-usb", +static const TypeInfo ehci_type_info = { + .name = TYPE_SYS_BUS_EHCI, .parent = TYPE_SYS_BUS_DEVICE, .instance_size = sizeof(EHCISysBusState), + .abstract = true, .class_init = ehci_sysbus_class_init, }; +static const TypeInfo ehci_xlnx_type_info = { + .name = "xlnx,ps7-usb", + .parent = TYPE_SYS_BUS_EHCI, +}; + static void ehci_sysbus_register_types(void) { + type_register_static(&ehci_type_info); type_register_static(&ehci_xlnx_type_info); } -- cgit v1.2.1