[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 06/26] q35: use type-safe cast instead of directly a
From: |
Hu Tao |
Subject: |
[Qemu-devel] [PATCH 06/26] q35: use type-safe cast instead of directly access of parent dev |
Date: |
Sat, 22 Jun 2013 16:50:18 +0800 |
And remove variables if possible.
Cc: "Michael S. Tsirkin" <address@hidden>
Cc: Paolo Bonzini <address@hidden>
Cc: Alex Williamson <address@hidden>
Cc: Anthony Liguori <address@hidden>
Cc: Jason Baron <address@hidden>
Signed-off-by: Hu Tao <address@hidden>
---
hw/pci-host/q35.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c
index bbecee6..bb5d506 100644
--- a/hw/pci-host/q35.c
+++ b/hw/pci-host/q35.c
@@ -36,7 +36,7 @@
static void q35_host_realize(DeviceState *dev, Error **errp)
{
- PCIHostState *pci = DO_UPCAST(PCIHostState, busdev.qdev, dev);
+ PCIHostState *pci = PCI_HOST_BRIDGE(dev);
Q35PCIHost *s = Q35_HOST_DEVICE(dev);
SysBusDevice *b = SYS_BUS_DEVICE(dev);
@@ -104,9 +104,8 @@ static const TypeInfo q35_host_info = {
static void mch_update_pciexbar(MCHPCIState *mch)
{
PCIDevice *pci_dev = &mch->d;
- BusState *bus = qdev_get_parent_bus(&pci_dev->qdev);
+ BusState *bus = qdev_get_parent_bus(DEVICE(pci_dev));
DeviceState *qdev = bus->parent;
- Q35PCIHost *s = Q35_HOST_DEVICE(qdev);
uint64_t pciexbar;
int enable;
@@ -138,18 +137,19 @@ static void mch_update_pciexbar(MCHPCIState *mch)
break;
}
addr = pciexbar & addr_mask;
- pcie_host_mmcfg_update(&s->host, enable, addr, length);
+ pcie_host_mmcfg_update(PCIE_HOST_BRIDGE(qdev), enable, addr, length);
}
/* PAM */
static void mch_update_pam(MCHPCIState *mch)
{
+ PCIDevice *pd = PCI_DEVICE(mch);
int i;
memory_region_transaction_begin();
for (i = 0; i < 13; i++) {
pam_update(&mch->pam_regions[i], i,
- mch->d.config[MCH_HOST_BRIDGE_PAM0 + ((i + 1) / 2)]);
+ pd->config[MCH_HOST_BRIDGE_PAM0 + ((i + 1) / 2)]);
}
memory_region_transaction_commit();
}
@@ -157,8 +157,10 @@ static void mch_update_pam(MCHPCIState *mch)
/* SMRAM */
static void mch_update_smram(MCHPCIState *mch)
{
+ PCIDevice *pd = PCI_DEVICE(mch);
+
memory_region_transaction_begin();
- smram_update(&mch->smram_region, mch->d.config[MCH_HOST_BRDIGE_SMRAM],
+ smram_update(&mch->smram_region, pd->config[MCH_HOST_BRDIGE_SMRAM],
mch->smm_enabled);
memory_region_transaction_commit();
}
@@ -166,9 +168,10 @@ static void mch_update_smram(MCHPCIState *mch)
static void mch_set_smm(int smm, void *arg)
{
MCHPCIState *mch = arg;
+ PCIDevice *pd = PCI_DEVICE(mch);
memory_region_transaction_begin();
- smram_set_smm(&mch->smm_enabled, smm, mch->d.config[MCH_HOST_BRDIGE_SMRAM],
+ smram_set_smm(&mch->smm_enabled, smm, pd->config[MCH_HOST_BRDIGE_SMRAM],
&mch->smram_region);
memory_region_transaction_commit();
}
--
1.8.3.1
- [Qemu-devel] [PATCH 02/26] ohci: QOM'ify some more, (continued)
- [Qemu-devel] [PATCH 02/26] ohci: QOM'ify some more, Hu Tao, 2013/06/22
- [Qemu-devel] [PATCH 04/26] i440fx: use type-safe cast instead of directly access of parent dev, Hu Tao, 2013/06/22
- [Qemu-devel] [PATCH 09/26] pflash_cfi01: use realize for pflash_cfi01, Hu Tao, 2013/06/22
- [Qemu-devel] [PATCH 07/26] fdc: use realize for fdc., Hu Tao, 2013/06/22
- [Qemu-devel] [PATCH 05/26] q35: use realize for q35 host, Hu Tao, 2013/06/22
- [Qemu-devel] [PATCH 10/26] pflash-cfi01: QOM'ify some more, Hu Tao, 2013/06/22
- [Qemu-devel] [PATCH 12/26] pflash-cfi02: QOM'ify some more, Hu Tao, 2013/06/22
- [Qemu-devel] [PATCH 11/26] pflash_cfi02: use realize for pflash_cfi02, Hu Tao, 2013/06/22
- [Qemu-devel] [PATCH 08/26] fdc: QOM'ify some more, Hu Tao, 2013/06/22
- [Qemu-devel] [PATCH 14/26] ahci: QOM'ify some more, Hu Tao, 2013/06/22
- [Qemu-devel] [PATCH 06/26] q35: use type-safe cast instead of directly access of parent dev,
Hu Tao <=
- [Qemu-devel] [PATCH 15/26] fwcfg: use realize for fwcfg, Hu Tao, 2013/06/22
- [Qemu-devel] [PATCH 16/26] fwcfg: QOM'ify some more, Hu Tao, 2013/06/22
- [Qemu-devel] [PATCH 17/26] scsi esp: use realize for scsi esp, Hu Tao, 2013/06/22
- [Qemu-devel] [PATCH 13/26] ahci: use realize for ahci, Hu Tao, 2013/06/22
- [Qemu-devel] [PATCH 21/26] kvmclock: use realize for kvmclock, Hu Tao, 2013/06/22