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 --- usb-linux.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'usb-linux.c') diff --git a/usb-linux.c b/usb-linux.c index a337db5..e7fc9ec 100644 --- a/usb-linux.c +++ b/usb-linux.c @@ -1402,8 +1402,19 @@ static const VMStateDescription vmstate_usb_host = { .unmigratable = 1, }; +static Property usb_host_dev_properties[] = { + DEFINE_PROP_UINT32("hostbus", USBHostDevice, match.bus_num, 0), + DEFINE_PROP_UINT32("hostaddr", USBHostDevice, match.addr, 0), + DEFINE_PROP_STRING("hostport", USBHostDevice, match.port), + DEFINE_PROP_HEX32("vendorid", USBHostDevice, match.vendor_id, 0), + DEFINE_PROP_HEX32("productid", USBHostDevice, match.product_id, 0), + DEFINE_PROP_UINT32("isobufs", USBHostDevice, iso_urb_count, 4), + DEFINE_PROP_END_OF_LIST(), +}; + static void usb_host_class_initfn(ObjectClass *klass, void *data) { + DeviceClass *dc = DEVICE_CLASS(klass); USBDeviceClass *uc = USB_DEVICE_CLASS(klass); uc->init = usb_host_initfn; @@ -1414,27 +1425,20 @@ static void usb_host_class_initfn(ObjectClass *klass, void *data) uc->handle_control = usb_host_handle_control; uc->handle_reset = usb_host_handle_reset; uc->handle_destroy = usb_host_handle_destroy; + dc->vmsd = &vmstate_usb_host; + dc->props = usb_host_dev_properties; } -static struct DeviceInfo usb_host_dev_info = { - .name = "usb-host", - .size = sizeof(USBHostDevice), - .vmsd = &vmstate_usb_host, - .class_init= usb_host_class_initfn, - .props = (Property[]) { - DEFINE_PROP_UINT32("hostbus", USBHostDevice, match.bus_num, 0), - DEFINE_PROP_UINT32("hostaddr", USBHostDevice, match.addr, 0), - DEFINE_PROP_STRING("hostport", USBHostDevice, match.port), - DEFINE_PROP_HEX32("vendorid", USBHostDevice, match.vendor_id, 0), - DEFINE_PROP_HEX32("productid", USBHostDevice, match.product_id, 0), - DEFINE_PROP_UINT32("isobufs", USBHostDevice, iso_urb_count, 4), - DEFINE_PROP_END_OF_LIST(), - }, +static TypeInfo usb_host_dev_info = { + .name = "usb-host", + .parent = TYPE_USB_DEVICE, + .instance_size = sizeof(USBHostDevice), + .class_init = usb_host_class_initfn, }; static void usb_host_register_devices(void) { - usb_qdev_register(&usb_host_dev_info); + type_register_static(&usb_host_dev_info); usb_legacy_register("usb-host", "host", usb_host_device_open); } device_init(usb_host_register_devices) -- cgit v1.1