aboutsummaryrefslogtreecommitdiff
path: root/hw/pci.c
diff options
context:
space:
mode:
authorAnthony Liguori <aliguori@us.ibm.com>2011-12-04 11:08:36 -0600
committerAnthony Liguori <aliguori@us.ibm.com>2012-01-27 10:50:34 -0600
commit30fbb9fc7cd73abc32ff71ceb59e9a3be37ac128 (patch)
tree25aa7ff76f8db648bff269cf169c00d28260ec1f /hw/pci.c
parent32fea4025bfb80f2dbc5c3ce415703af28d85f63 (diff)
qdev: move qdev->info to class
Right now, DeviceInfo acts as the class for qdev. In order to switch to a proper ObjectClass derivative, we need to ween all of the callers off of interacting directly with the info pointer. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/pci.c')
-rw-r--r--hw/pci.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/hw/pci.c b/hw/pci.c
index ab3b53d985..5345079ce7 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -841,7 +841,7 @@ static void pci_unregister_io_regions(PCIDevice *pci_dev)
static int pci_unregister_device(DeviceState *dev)
{
PCIDevice *pci_dev = DO_UPCAST(PCIDevice, qdev, dev);
- PCIDeviceInfo *info = DO_UPCAST(PCIDeviceInfo, qdev, dev->info);
+ PCIDeviceInfo *info = DO_UPCAST(PCIDeviceInfo, qdev, qdev_get_info(dev));
int ret = 0;
if (info->exit)
@@ -1531,7 +1531,7 @@ static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base)
static int pci_unplug_device(DeviceState *qdev)
{
PCIDevice *dev = DO_UPCAST(PCIDevice, qdev, qdev);
- PCIDeviceInfo *info = container_of(qdev->info, PCIDeviceInfo, qdev);
+ PCIDeviceInfo *info = container_of(qdev_get_info(qdev), PCIDeviceInfo, qdev);
if (info->no_hotplug) {
qerror_report(QERR_DEVICE_NO_HOTPLUG, info->qdev.name);
@@ -1544,7 +1544,9 @@ static int pci_unplug_device(DeviceState *qdev)
void pci_qdev_register(PCIDeviceInfo *info)
{
info->qdev.init = pci_qdev_init;
- info->qdev.unplug = pci_unplug_device;
+ if (!info->qdev.unplug) {
+ info->qdev.unplug = pci_unplug_device;
+ }
info->qdev.exit = pci_unregister_device;
info->qdev.bus_info = &pci_bus_info;
qdev_register(&info->qdev);
@@ -1737,10 +1739,10 @@ static int pci_add_option_rom(PCIDevice *pdev, bool is_default_rom)
size = 1 << qemu_fls(size);
}
- if (pdev->qdev.info->vmsd)
- snprintf(name, sizeof(name), "%s.rom", pdev->qdev.info->vmsd->name);
+ if (qdev_get_info(&pdev->qdev)->vmsd)
+ snprintf(name, sizeof(name), "%s.rom", qdev_get_info(&pdev->qdev)->vmsd->name);
else
- snprintf(name, sizeof(name), "%s.rom", pdev->qdev.info->name);
+ snprintf(name, sizeof(name), "%s.rom", qdev_get_info(&pdev->qdev)->name);
pdev->has_rom = true;
memory_region_init_ram(&pdev->rom, name, size);
vmstate_register_ram(&pdev->rom, &pdev->qdev);
@@ -1981,7 +1983,7 @@ static int pci_qdev_find_recursive(PCIBus *bus,
}
/* roughly check if given qdev is pci device */
- if (qdev->info->init == &pci_qdev_init &&
+ if (qdev_get_info(qdev)->init == &pci_qdev_init &&
qdev->parent_bus->info == &pci_bus_info) {
*pdev = DO_UPCAST(PCIDevice, qdev, qdev);
return 0;