diff options
author | Anthony Liguori <aliguori@us.ibm.com> | 2011-12-09 10:51:49 -0600 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2012-02-03 10:41:04 -0600 |
commit | 4be9f0d11cf2dbb1eb3f55b33c87d6df3aa7d578 (patch) | |
tree | 63f72eaf204e81336e4ab4341a10eaf6147c5f68 | |
parent | ba02430f1a681173cff5336c626d6edc5ea268db (diff) |
qdev: make DeviceInfo private
Introduce accessors and remove any code that directly accesses DeviceInfo
members.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
-rw-r--r-- | hw/pci.c | 13 | ||||
-rw-r--r-- | hw/qdev-properties.c | 4 | ||||
-rw-r--r-- | hw/qdev.c | 30 | ||||
-rw-r--r-- | hw/qdev.h | 24 |
4 files changed, 48 insertions, 23 deletions
@@ -1673,6 +1673,7 @@ static int pci_add_option_rom(PCIDevice *pdev, bool is_default_rom) char *path; void *ptr; char name[32]; + const VMStateDescription *vmsd; if (!pdev->romfile) return 0; @@ -1709,10 +1710,13 @@ static int pci_add_option_rom(PCIDevice *pdev, bool is_default_rom) size = 1 << qemu_fls(size); } - if (qdev_get_info(&pdev->qdev)->vmsd) - snprintf(name, sizeof(name), "%s.rom", qdev_get_info(&pdev->qdev)->vmsd->name); - else + vmsd = qdev_get_vmsd(DEVICE(pdev)); + + if (vmsd) { + snprintf(name, sizeof(name), "%s.rom", vmsd->name); + } else { snprintf(name, sizeof(name), "%s.rom", object_get_typename(OBJECT(pdev))); + } pdev->has_rom = true; memory_region_init_ram(&pdev->rom, name, size); vmstate_register_ram(&pdev->rom, &pdev->qdev); @@ -1953,8 +1957,7 @@ static int pci_qdev_find_recursive(PCIBus *bus, } /* roughly check if given qdev is pci device */ - if (qdev_get_info(qdev)->init == &pci_qdev_init && - qdev->parent_bus->info == &pci_bus_info) { + if (object_dynamic_cast(OBJECT(qdev), TYPE_PCI_DEVICE)) { *pdev = PCI_DEVICE(qdev); return 0; } diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c index 028bee7da6..2e3ef702ea 100644 --- a/hw/qdev-properties.c +++ b/hw/qdev-properties.c @@ -1015,7 +1015,7 @@ static Property *qdev_prop_find(DeviceState *dev, const char *name) Property *prop; /* device properties */ - prop = qdev_prop_walk(qdev_get_info(dev)->props, name); + prop = qdev_prop_walk(qdev_get_props(dev), name); if (prop) return prop; @@ -1221,7 +1221,7 @@ void qdev_prop_set_globals(DeviceState *dev) QTAILQ_FOREACH(prop, &global_props, next) { if (strcmp(object_get_typename(OBJECT(dev)), prop->driver) != 0 && - strcmp(qdev_get_info(dev)->bus_info->name, prop->driver) != 0) { + strcmp(qdev_get_bus_info(dev)->name, prop->driver) != 0) { continue; } if (qdev_prop_parse(dev, prop->property, prop->value) != 0) { @@ -60,11 +60,39 @@ static void qdev_subclass_init(ObjectClass *klass, void *data) } } -DeviceInfo *qdev_get_info(DeviceState *dev) +static DeviceInfo *qdev_get_info(DeviceState *dev) { return DEVICE_GET_CLASS(dev)->info; } +const VMStateDescription *qdev_get_vmsd(DeviceState *dev) +{ + return qdev_get_info(dev)->vmsd; +} + +BusInfo *qdev_get_bus_info(DeviceState *dev) +{ + return qdev_get_info(dev)->bus_info; +} + +Property *qdev_get_props(DeviceState *dev) +{ + return qdev_get_info(dev)->props; +} + +const char *qdev_fw_name(DeviceState *dev) +{ + DeviceInfo *info = qdev_get_info(dev); + + if (info->fw_name) { + return info->fw_name; + } else if (info->alias) { + return info->alias; + } + + return object_get_typename(OBJECT(dev)); +} + void qdev_register_subclass(DeviceInfo *info, const char *parent) { TypeInfo type_info = {}; @@ -405,22 +405,8 @@ void qdev_prop_set_globals(DeviceState *dev); void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev, Property *prop, const char *value); -DeviceInfo *qdev_get_info(DeviceState *dev); - -static inline const char *qdev_fw_name(DeviceState *dev) -{ - DeviceInfo *info = qdev_get_info(dev); - - if (info->fw_name) { - return info->fw_name; - } else if (info->alias) { - return info->alias; - } - - return object_get_typename(OBJECT(dev)); -} - char *qdev_get_fw_dev_path(DeviceState *dev); + /* This is a nasty hack to allow passing a NULL bus to qdev_create. */ extern struct BusInfo system_bus_info; @@ -668,4 +654,12 @@ void qdev_machine_init(void); */ void device_reset(DeviceState *dev); +const VMStateDescription *qdev_get_vmsd(DeviceState *dev); + +const char *qdev_fw_name(DeviceState *dev); + +BusInfo *qdev_get_bus_info(DeviceState *dev); + +Property *qdev_get_props(DeviceState *dev); + #endif |