aboutsummaryrefslogtreecommitdiff
path: root/hw/usb-ccid.c
diff options
context:
space:
mode:
authorAnthony Liguori <aliguori@us.ibm.com>2011-12-07 21:34:16 -0600
committerAnthony Liguori <aliguori@us.ibm.com>2012-02-03 10:41:06 -0600
commit39bffca2030950ef6efe57c2fac8327a45ae1015 (patch)
tree325262f44978e6116c9e43f688c900e08ee83738 /hw/usb-ccid.c
parent212ad111683a5b5a79a74d6141a4b75f532a4c8f (diff)
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 <aliguori@us.ibm.com>
Diffstat (limited to 'hw/usb-ccid.c')
-rw-r--r--hw/usb-ccid.c43
1 files changed, 24 insertions, 19 deletions
diff --git a/hw/usb-ccid.c b/hw/usb-ccid.c
index a261d7d34d..844f873290 100644
--- a/hw/usb-ccid.c
+++ b/hw/usb-ccid.c
@@ -1184,14 +1184,6 @@ static int ccid_card_init(DeviceState *qdev, DeviceInfo *base)
return ret;
}
-void ccid_card_qdev_register(DeviceInfo *info)
-{
- info->bus_info = &ccid_bus_info;
- info->init = ccid_card_init;
- info->exit = ccid_card_exit;
- qdev_register_subclass(info, TYPE_CCID_CARD);
-}
-
static int ccid_initfn(USBDevice *dev)
{
USBCCIDState *s = DO_UPCAST(USBCCIDState, dev, dev);
@@ -1315,8 +1307,14 @@ static VMStateDescription ccid_vmstate = {
}
};
+static Property ccid_properties[] = {
+ DEFINE_PROP_UINT8("debug", USBCCIDState, debug, 0),
+ DEFINE_PROP_END_OF_LIST(),
+};
+
static void ccid_class_initfn(ObjectClass *klass, void *data)
{
+ DeviceClass *dc = DEVICE_CLASS(klass);
USBDeviceClass *uc = USB_DEVICE_CLASS(klass);
uc->init = ccid_initfn;
@@ -1327,32 +1325,39 @@ static void ccid_class_initfn(ObjectClass *klass, void *data)
uc->handle_control = ccid_handle_control;
uc->handle_data = ccid_handle_data;
uc->handle_destroy = ccid_handle_destroy;
+ dc->desc = "CCID Rev 1.1 smartcard reader";
+ dc->vmsd = &ccid_vmstate;
+ dc->props = ccid_properties;
}
-static struct DeviceInfo ccid_info = {
- .name = CCID_DEV_NAME,
- .desc = "CCID Rev 1.1 smartcard reader",
- .size = sizeof(USBCCIDState),
- .class_init= ccid_class_initfn,
- .vmsd = &ccid_vmstate,
- .props = (Property[]) {
- DEFINE_PROP_UINT8("debug", USBCCIDState, debug, 0),
- DEFINE_PROP_END_OF_LIST(),
- },
+static TypeInfo ccid_info = {
+ .name = CCID_DEV_NAME,
+ .parent = TYPE_USB_DEVICE,
+ .instance_size = sizeof(USBCCIDState),
+ .class_init = ccid_class_initfn,
};
+static void ccid_card_class_init(ObjectClass *klass, void *data)
+{
+ DeviceClass *k = DEVICE_CLASS(klass);
+ k->bus_info = &ccid_bus_info;
+ k->init = ccid_card_init;
+ k->exit = ccid_card_exit;
+}
+
static TypeInfo ccid_card_type_info = {
.name = TYPE_CCID_CARD,
.parent = TYPE_DEVICE,
.instance_size = sizeof(CCIDCardState),
.abstract = true,
.class_size = sizeof(CCIDCardClass),
+ .class_init = ccid_card_class_init,
};
static void ccid_register_devices(void)
{
type_register_static(&ccid_card_type_info);
- usb_qdev_register(&ccid_info);
+ type_register_static(&ccid_info);
usb_legacy_register(CCID_DEV_NAME, "ccid", NULL);
}
device_init(ccid_register_devices)