[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFT PATCH v1 17/30] pci/*: QOM casting sweep
From: |
peter . crosthwaite |
Subject: |
[Qemu-devel] [RFT PATCH v1 17/30] pci/*: QOM casting sweep |
Date: |
Tue, 11 Jun 2013 16:52:53 +1000 |
From: Peter Crosthwaite <address@hidden>
Use standard QOM cast macro. Remove usages of DO_UPCAST, container_of()
and direct -> style upcasting.
Signed-off-by: Peter Crosthwaite <address@hidden>
---
hw/pci/pci-hotplug.c | 18 ++++++++++--------
hw/pci/pci.c | 17 +++++++++--------
hw/pci/pcie.c | 4 ++--
hw/pci/shpc.c | 8 ++++----
4 files changed, 25 insertions(+), 22 deletions(-)
diff --git a/hw/pci/pci-hotplug.c b/hw/pci/pci-hotplug.c
index 12287d1..0009190 100644
--- a/hw/pci/pci-hotplug.c
+++ b/hw/pci/pci-hotplug.c
@@ -129,7 +129,7 @@ int pci_drive_hot_add(Monitor *mon, const QDict *qdict,
DriveInfo *dinfo)
monitor_printf(mon, "no pci device with address %s\n", pci_addr);
goto err;
}
- if (scsi_hot_add(mon, &dev->qdev, dinfo, 1) != 0) {
+ if (scsi_hot_add(mon, DEVICE(dev), dinfo, 1) != 0) {
goto err;
}
break;
@@ -193,11 +193,12 @@ static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon,
switch (type) {
case IF_SCSI:
dev = pci_create(bus, devfn, "lsi53c895a");
- if (qdev_init(&dev->qdev) < 0)
+ if (qdev_init(DEVICE(dev)) < 0) {
dev = NULL;
+ }
if (dev && dinfo) {
- if (scsi_hot_add(mon, &dev->qdev, dinfo, 0) != 0) {
- qdev_unplug(&dev->qdev, NULL);
+ if (scsi_hot_add(mon, DEVICE(dev), dinfo, 0) != 0) {
+ qdev_unplug(DEVICE(dev), NULL);
dev = NULL;
}
}
@@ -208,13 +209,14 @@ static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon,
return NULL;
}
dev = pci_create(bus, devfn, "virtio-blk-pci");
- if (qdev_prop_set_drive(&dev->qdev, "drive", dinfo->bdrv) < 0) {
- qdev_free(&dev->qdev);
+ if (qdev_prop_set_drive(DEVICE(dev), "drive", dinfo->bdrv) < 0) {
+ qdev_free(DEVICE(dev));
dev = NULL;
break;
}
- if (qdev_init(&dev->qdev) < 0)
+ if (qdev_init(DEVICE(dev)) < 0) {
dev = NULL;
+ }
break;
default:
dev = NULL;
@@ -276,7 +278,7 @@ static int pci_device_hot_remove(Monitor *mon, const char
*pci_addr)
return -1;
}
- qdev_unplug(&d->qdev, &local_err);
+ qdev_unplug(DEVICE(d), &local_err);
if (error_is_set(&local_err)) {
monitor_printf(mon, "%s\n", error_get_pretty(local_err));
error_free(local_err);
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index bb3879b..01a754d 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -177,7 +177,7 @@ void pci_device_reset(PCIDevice *dev)
{
int r;
- qdev_reset_all(&dev->qdev);
+ qdev_reset_all(DEVICE(dev));
dev->irq_state = 0;
pci_update_irq_status(dev);
@@ -1449,6 +1449,7 @@ static PciBridgeInfo *qmp_query_pci_bridge(PCIDevice
*dev, PCIBus *bus,
static PciDeviceInfo *qmp_query_pci_device(PCIDevice *dev, PCIBus *bus,
int bus_num)
{
+ DeviceState *d = DEVICE(dev);
const pci_class_desc *desc;
PciDeviceInfo *info;
uint8_t type;
@@ -1470,7 +1471,7 @@ static PciDeviceInfo *qmp_query_pci_device(PCIDevice
*dev, PCIBus *bus,
info->id.vendor = pci_get_word(dev->config + PCI_VENDOR_ID);
info->id.device = pci_get_word(dev->config + PCI_DEVICE_ID);
info->regions = qmp_query_pci_regions(dev);
- info->qdev_id = g_strdup(dev->qdev.id ? dev->qdev.id : "");
+ info->qdev_id = g_strdup(d->id ? d->id : "");
if (dev->config[PCI_INTERRUPT_PIN] != 0) {
info->has_irq = true;
@@ -1594,7 +1595,7 @@ PCIDevice *pci_nic_init(NICInfo *nd, const char
*default_model,
}
pci_dev = pci_create(bus, devfn, pci_nic_names[i]);
- dev = &pci_dev->qdev;
+ dev = DEVICE(pci_dev);
qdev_set_nic_properties(dev, nd);
if (qdev_init(dev) < 0)
return NULL;
@@ -1734,7 +1735,7 @@ static int pci_qdev_init(DeviceState *qdev)
qdev->hotplugged ? PCI_HOTPLUG_ENABLED:
PCI_COLDPLUG_ENABLED);
if (rc != 0) {
- int r = pci_unregister_device(&pci_dev->qdev);
+ int r = pci_unregister_device(DEVICE(pci_dev));
assert(!r);
return rc;
}
@@ -1771,7 +1772,7 @@ PCIDevice *pci_create_simple_multifunction(PCIBus *bus,
int devfn,
const char *name)
{
PCIDevice *dev = pci_create_multifunction(bus, devfn, multifunction, name);
- qdev_init_nofail(&dev->qdev);
+ qdev_init_nofail(DEVICE(dev));
return dev;
}
@@ -1949,7 +1950,7 @@ static int pci_add_option_rom(PCIDevice *pdev, bool
is_default_rom)
}
pdev->has_rom = true;
memory_region_init_ram(&pdev->rom, name, size);
- vmstate_register_ram(&pdev->rom, &pdev->qdev);
+ vmstate_register_ram(&pdev->rom, DEVICE(pdev));
ptr = memory_region_get_ram_ptr(&pdev->rom);
load_image(path, ptr);
g_free(path);
@@ -1969,7 +1970,7 @@ static void pci_del_option_rom(PCIDevice *pdev)
if (!pdev->has_rom)
return;
- vmstate_unregister_ram(&pdev->rom, &pdev->qdev);
+ vmstate_unregister_ram(&pdev->rom, DEVICE(pdev));
memory_region_destroy(&pdev->rom);
pdev->has_rom = false;
}
@@ -2129,7 +2130,7 @@ static char *pcibus_get_fw_dev_path(DeviceState *dev)
static char *pcibus_get_dev_path(DeviceState *dev)
{
- PCIDevice *d = container_of(dev, PCIDevice, qdev);
+ PCIDevice *d = PCI_DEVICE(dev);
PCIDevice *t;
int slot_depth;
/* Path format: Domain:00:Slot.Function:Slot.Function....:Slot.Function.
diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c
index 62bd0b8..db4bca8 100644
--- a/hw/pci/pcie.c
+++ b/hw/pci/pcie.c
@@ -251,7 +251,7 @@ static int pcie_cap_slot_hotplug(DeviceState *qdev,
PCI_EXP_SLTSTA_PDS);
pcie_cap_slot_event(d, PCI_EXP_HP_EV_PDC);
} else {
- qdev_free(&pci_dev->qdev);
+ qdev_free(DEVICE(pci_dev));
pci_word_test_and_clear_mask(exp_cap + PCI_EXP_SLTSTA,
PCI_EXP_SLTSTA_PDS);
pcie_cap_slot_event(d, PCI_EXP_HP_EV_PDC);
@@ -306,7 +306,7 @@ void pcie_cap_slot_init(PCIDevice *dev, uint16_t slot)
dev->exp.hpev_notified = false;
pci_bus_hotplug(pci_bridge_get_sec_bus(DO_UPCAST(PCIBridge, dev, dev)),
- pcie_cap_slot_hotplug, &dev->qdev);
+ pcie_cap_slot_hotplug, DEVICE(dev));
}
void pcie_cap_slot_reset(PCIDevice *dev)
diff --git a/hw/pci/shpc.c b/hw/pci/shpc.c
index d35c2ee..aa45e77 100644
--- a/hw/pci/shpc.c
+++ b/hw/pci/shpc.c
@@ -252,9 +252,9 @@ static void shpc_free_devices_in_slot(SHPCDevice *shpc, int
slot)
for (devfn = PCI_DEVFN(pci_slot, 0);
devfn <= PCI_DEVFN(pci_slot, PCI_FUNC_MAX - 1);
++devfn) {
- PCIDevice *affected_dev = shpc->sec_bus->devices[devfn];
+ DeviceState *affected_dev = DEVICE(shpc->sec_bus->devices[devfn]);
if (affected_dev) {
- qdev_free(&affected_dev->qdev);
+ qdev_free(affected_dev);
}
}
}
@@ -497,7 +497,7 @@ static int shpc_device_hotplug(DeviceState *qdev, PCIDevice
*affected_dev,
int pci_slot = PCI_SLOT(affected_dev->devfn);
uint8_t state;
uint8_t led;
- PCIDevice *d = DO_UPCAST(PCIDevice, qdev, qdev);
+ PCIDevice *d = PCI_DEVICE(qdev);
SHPCDevice *shpc = d->shpc;
int slot = SHPC_PCI_TO_IDX(pci_slot);
if (pci_slot < SHPC_IDX_TO_PCI(0) || slot >= shpc->nslots) {
@@ -616,7 +616,7 @@ int shpc_init(PCIDevice *d, PCIBus *sec_bus, MemoryRegion
*bar, unsigned offset)
SHPC_SIZEOF(d));
shpc_cap_update_dword(d);
memory_region_add_subregion(bar, offset, &shpc->mmio);
- pci_bus_hotplug(sec_bus, shpc_device_hotplug, &d->qdev);
+ pci_bus_hotplug(sec_bus, shpc_device_hotplug, DEVICE(d));
d->cap_present |= QEMU_PCI_CAP_SHPC;
return 0;
--
1.8.3.rc1.44.gb387c77.dirty
- [Qemu-devel] [RFT PATCH v1 11/30] misc/pci-testdev: QOM Upcast Sweep, (continued)
- [Qemu-devel] [RFT PATCH v1 11/30] misc/pci-testdev: QOM Upcast Sweep, peter . crosthwaite, 2013/06/11
- [Qemu-devel] [RFT PATCH v1 12/30] virtio/virtio-pci: QOM casting sweep, peter . crosthwaite, 2013/06/11
- [Qemu-devel] [RFT PATCH v1 13/30] virtio/vmware_vga: QOM casting sweep, peter . crosthwaite, 2013/06/11
- [Qemu-devel] [RFT PATCH v1 14/30] misc/ivshmem: QOM Upcast Sweep, peter . crosthwaite, 2013/06/11
- [Qemu-devel] [RFT PATCH v1 15/30] xen/xen_platform: QOM casting sweep, peter . crosthwaite, 2013/06/11
- [Qemu-devel] [RFT PATCH v1 16/30] isa/*: QOM casting sweep, peter . crosthwaite, 2013/06/11
- [Qemu-devel] [RFT PATCH v1 17/30] pci/*: QOM casting sweep,
peter . crosthwaite <=
- [Qemu-devel] [RFT PATCH v1 18/30] pci-bridge/pci_bridge_dev: Don't use DO_UPCAST, peter . crosthwaite, 2013/06/11
- [Qemu-devel] [RFT PATCH v1 19/30] pci-bridge/*: substitute ->qdev casts with DEVICE(), peter . crosthwaite, 2013/06/11
- [Qemu-devel] [RFT PATCH v1 20/30] misc/vfio: substitute ->qdev casts with DEVICE(), peter . crosthwaite, 2013/06/11
- [Qemu-devel] [RFT PATCH v1 21/30] net/eepro100: substitute ->qdev casts with DEVICE(), peter . crosthwaite, 2013/06/11
- [Qemu-devel] [RFT PATCH v1 22/30] net/ne2000: substitute ->qdev casts with DEVICE(), peter . crosthwaite, 2013/06/11
- [Qemu-devel] [RFT PATCH v1 23/30] usb/*: substitute ->qdev casts with DEVICE(), peter . crosthwaite, 2013/06/11
- [Qemu-devel] [RFT PATCH v1 24/30] watchdog/wdt_i6300esb: substitute ->qdev casts with DEVICE(), peter . crosthwaite, 2013/06/11
- [Qemu-devel] [RFT PATCH v1 25/30] scsi/vmw_pvscsi: substitute ->qdev casts with DEVICE(), peter . crosthwaite, 2013/06/11
- [Qemu-devel] [RFT PATCH v1 26/30] i2c/smbus_ich9: substitute ->qdev casts with DEVICE(), peter . crosthwaite, 2013/06/11
- [Qemu-devel] [RFT PATCH v1 27/30] ide/cmd646: substitute ->qdev casts with DEVICE(), peter . crosthwaite, 2013/06/11