From 39bffca2030950ef6efe57c2fac8327a45ae1015 Mon Sep 17 00:00:00 2001 From: Anthony Liguori Date: Wed, 7 Dec 2011 21:34:16 -0600 Subject: qdev: register all types natively through QEMU Object Model This was done in a mostly automated fashion. I did it in three steps and then rebased it into a single step which avoids repeatedly touching every file in the tree. The first step was a sed-based addition of the parent type to the subclass registration functions. The second step was another sed-based removal of subclass registration functions while also adding virtual functions from the base class into a class_init function as appropriate. Finally, a python script was used to convert the DeviceInfo structures and qdev_register_subclass functions to TypeInfo structures, class_init functions, and type_register_static calls. We are almost fully converted to QOM after this commit. Signed-off-by: Anthony Liguori --- hw/usb-ohci.c | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) (limited to 'hw/usb-ohci.c') diff --git a/hw/usb-ohci.c b/hw/usb-ohci.c index 3437da1..425030f 100644 --- a/hw/usb-ohci.c +++ b/hw/usb-ohci.c @@ -1845,44 +1845,50 @@ static Property ohci_pci_properties[] = { static void ohci_pci_class_init(ObjectClass *klass, void *data) { + DeviceClass *dc = DEVICE_CLASS(klass); PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); k->init = usb_ohci_initfn_pci; k->vendor_id = PCI_VENDOR_ID_APPLE; k->device_id = PCI_DEVICE_ID_APPLE_IPID_USB; k->class_id = PCI_CLASS_SERIAL_USB; + dc->desc = "Apple USB Controller"; + dc->props = ohci_pci_properties; } -static DeviceInfo ohci_pci_info = { - .name = "pci-ohci", - .desc = "Apple USB Controller", - .size = sizeof(OHCIPCIState), - .props = ohci_pci_properties, - .class_init = ohci_pci_class_init, +static TypeInfo ohci_pci_info = { + .name = "pci-ohci", + .parent = TYPE_PCI_DEVICE, + .instance_size = sizeof(OHCIPCIState), + .class_init = ohci_pci_class_init, +}; + +static Property ohci_sysbus_properties[] = { + DEFINE_PROP_UINT32("num-ports", OHCISysBusState, num_ports, 3), + DEFINE_PROP_TADDR("dma-offset", OHCISysBusState, dma_offset, 3), + DEFINE_PROP_END_OF_LIST(), }; static void ohci_sysbus_class_init(ObjectClass *klass, void *data) { + DeviceClass *dc = DEVICE_CLASS(klass); SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(klass); sbc->init = ohci_init_pxa; + dc->desc = "OHCI USB Controller"; + dc->props = ohci_sysbus_properties; } -static DeviceInfo ohci_sysbus_info = { - .name = "sysbus-ohci", - .desc = "OHCI USB Controller", - .size = sizeof(OHCISysBusState), - .class_init = ohci_sysbus_class_init, - .props = (Property[]) { - DEFINE_PROP_UINT32("num-ports", OHCISysBusState, num_ports, 3), - DEFINE_PROP_TADDR("dma-offset", OHCISysBusState, dma_offset, 3), - DEFINE_PROP_END_OF_LIST(), - } +static TypeInfo ohci_sysbus_info = { + .name = "sysbus-ohci", + .parent = TYPE_SYS_BUS_DEVICE, + .instance_size = sizeof(OHCISysBusState), + .class_init = ohci_sysbus_class_init, }; static void ohci_register(void) { - pci_qdev_register(&ohci_pci_info); - sysbus_register_withprop(&ohci_sysbus_info); + type_register_static(&ohci_pci_info); + type_register_static(&ohci_sysbus_info); } device_init(ohci_register); -- cgit v1.1