From: "Andreas Färber" <afaerber@suse.de>
To: Hu Tao <hutao@cn.fujitsu.com>
Cc: qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH v2 06/26] q35: use type-safe cast instead of directly access of parent dev
Date: Mon, 08 Jul 2013 01:05:00 +0200 [thread overview]
Message-ID: <51D9F41C.4000200@suse.de> (raw)
In-Reply-To: <7bdbde3da2d08d4971bdf3b3e07ba0815d1e98b3.1372673778.git.hutao@cn.fujitsu.com>
[-- Attachment #1: Type: text/plain, Size: 631 bytes --]
Am 01.07.2013 12:18, schrieb Hu Tao:
> And remove variables if possible.
>
> Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
> ---
> hw/pci-host/q35.c | 35 ++++++++++++++++++-----------------
> 1 file changed, 18 insertions(+), 17 deletions(-)
Thanks, converted the remaining ones as attached and queued on qom-next:
https://github.com/afaerber/qemu-cpu/commits/qom-next
Do note that we will need to later touch the PCIBus again to use
pci_bus_new_inplace().
Andreas
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
[-- Attachment #2: q35.diff --]
[-- Type: text/x-patch, Size: 3138 bytes --]
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index e4cde04..480d981 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -59,6 +59,7 @@ static void pc_q35_init(QEMUMachineInitArgs *args)
const char *boot_device = args->boot_device;
ram_addr_t below_4g_mem_size, above_4g_mem_size;
Q35PCIHost *q35_host;
+ PCIDevice *q35_pci;
PCIBus *host_bus;
PCIDevice *lpc;
BusState *idebus[MAX_SATA_PORTS];
@@ -133,7 +134,8 @@ static void pc_q35_init(QEMUMachineInitArgs *args)
q35_host->mch.above_4g_mem_size = above_4g_mem_size;
/* pci */
qdev_init_nofail(DEVICE(q35_host));
- host_bus = q35_host->host.pci.bus;
+ q35_pci = PCI_DEVICE(q35_host);
+ host_bus = q35_pci->bus;
/* create ISA bus */
lpc = pci_create_simple_multifunction(host_bus, PCI_DEVFN(ICH9_LPC_DEV,
ICH9_LPC_FUNC), true,
diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c
index f92f661..beda3e6 100644
--- a/hw/pci-host/q35.c
+++ b/hw/pci-host/q35.c
@@ -62,7 +62,7 @@ static int q35_host_init(SysBusDevice *dev)
}
static Property mch_props[] = {
- DEFINE_PROP_UINT64("MCFG", Q35PCIHost, host.base_addr,
+ DEFINE_PROP_UINT64("MCFG", Q35PCIHost, parent_obj.base_addr,
MCH_HOST_BRIDGE_PCIEXBAR_DEFAULT),
DEFINE_PROP_END_OF_LIST(),
};
@@ -102,9 +102,9 @@ static const TypeInfo q35_host_info = {
/* PCIe MMCFG */
static void mch_update_pciexbar(MCHPCIState *mch)
{
- PCIDevice *pci_dev = &mch->d;
- BusState *bus = qdev_get_parent_bus(DEVICE(pci_dev));
- DeviceState *qdev = bus->parent;
+ PCIDevice *pci_dev = PCI_DEVICE(mch);
+ BusState *bus = qdev_get_parent_bus(DEVICE(mch));
+ PCIExpressHost *pehb = PCIE_HOST_BRIDGE(bus->parent);
uint64_t pciexbar;
int enable;
@@ -136,7 +136,7 @@ static void mch_update_pciexbar(MCHPCIState *mch)
break;
}
addr = pciexbar & addr_mask;
- pcie_host_mmcfg_update(PCIE_HOST_BRIDGE(qdev), enable, addr, length);
+ pcie_host_mmcfg_update(pehb, enable, addr, length);
}
/* PAM */
@@ -220,7 +220,7 @@ static const VMStateDescription vmstate_mch = {
.minimum_version_id_old = 1,
.post_load = mch_post_load,
.fields = (VMStateField []) {
- VMSTATE_PCI_DEVICE(d, MCHPCIState),
+ VMSTATE_PCI_DEVICE(parent_obj, MCHPCIState),
VMSTATE_UINT8(smm_enabled, MCHPCIState),
VMSTATE_END_OF_LIST()
}
diff --git a/include/hw/pci-host/q35.h b/include/hw/pci-host/q35.h
index e182c82..1a8ff83 100644
--- a/include/hw/pci-host/q35.h
+++ b/include/hw/pci-host/q35.h
@@ -43,7 +43,10 @@
OBJECT_CHECK(MCHPCIState, (obj), TYPE_MCH_PCI_DEVICE)
typedef struct MCHPCIState {
- PCIDevice d;
+ /*< private >*/
+ PCIDevice parent_obj;
+ /*< public >*/
+
MemoryRegion *ram_memory;
MemoryRegion *pci_address_space;
MemoryRegion *system_memory;
@@ -58,7 +61,10 @@ typedef struct MCHPCIState {
} MCHPCIState;
typedef struct Q35PCIHost {
- PCIExpressHost host;
+ /*< private >*/
+ PCIExpressHost parent_obj;
+ /*< public >*/
+
MCHPCIState mch;
} Q35PCIHost;
[-- Attachment #3: q35a.diff --]
[-- Type: text/x-patch, Size: 941 bytes --]
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 480d981..bdac09e 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -59,7 +59,7 @@ static void pc_q35_init(QEMUMachineInitArgs *args)
const char *boot_device = args->boot_device;
ram_addr_t below_4g_mem_size, above_4g_mem_size;
Q35PCIHost *q35_host;
- PCIDevice *q35_pci;
+ PCIHostState *phb;
PCIBus *host_bus;
PCIDevice *lpc;
BusState *idebus[MAX_SATA_PORTS];
@@ -134,8 +134,8 @@ static void pc_q35_init(QEMUMachineInitArgs *args)
q35_host->mch.above_4g_mem_size = above_4g_mem_size;
/* pci */
qdev_init_nofail(DEVICE(q35_host));
- q35_pci = PCI_DEVICE(q35_host);
- host_bus = q35_pci->bus;
+ phb = PCI_HOST_BRIDGE(q35_host);
+ host_bus = phb->bus;
/* create ISA bus */
lpc = pci_create_simple_multifunction(host_bus, PCI_DEVFN(ICH9_LPC_DEV,
ICH9_LPC_FUNC), true,
next prev parent reply other threads:[~2013-07-07 23:05 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-01 10:18 [Qemu-devel] [PATCH v2 00/26] use realizefn for SysBusDevice, part 1 Hu Tao
2013-07-01 10:18 ` [Qemu-devel] [PATCH v2 01/26] sysbus: document SysBusDeviceClass about @init Hu Tao
2013-07-03 1:19 ` Andreas Färber
2013-07-03 1:24 ` Hu Tao
2013-07-01 10:18 ` [Qemu-devel] [PATCH v2 02/26] ohci: QOM'ify some more Hu Tao
2013-07-03 1:52 ` Andreas Färber
2013-07-01 10:18 ` [Qemu-devel] [PATCH v2 03/26] ohci: use realize for ohci Hu Tao
2013-07-07 15:22 ` Andreas Färber
2013-07-01 10:18 ` [Qemu-devel] [PATCH v2 04/26] i440fx-pcihost: use realize for i440fx-pcihost Hu Tao
2013-07-07 21:24 ` Andreas Färber
2013-07-01 10:18 ` [Qemu-devel] [PATCH v2 05/26] i440fx: use type-safe cast instead of directly access of parent dev Hu Tao
2013-07-07 17:03 ` Andreas Färber
2013-07-01 10:18 ` [Qemu-devel] [PATCH v2 06/26] q35: " Hu Tao
2013-07-07 23:05 ` Andreas Färber [this message]
2013-07-01 10:18 ` [Qemu-devel] [PATCH v2 07/26] q35: use realize for q35 host Hu Tao
2013-07-08 1:20 ` Andreas Färber
2013-07-01 10:18 ` [Qemu-devel] [PATCH v2 08/26] fdc: QOM'ify some more Hu Tao
2013-07-01 10:18 ` [Qemu-devel] [PATCH v2 09/26] fdc: use realize for fdc Hu Tao
2013-07-21 9:27 ` Andreas Färber
2013-07-21 9:31 ` [Qemu-devel] [PATCH qom-next] fdc: Improve error propagation for QOM realize Andreas Färber
2013-07-22 7:38 ` Hu Tao
2013-07-22 8:26 ` Stefan Hajnoczi
2013-07-01 10:18 ` [Qemu-devel] [PATCH v2 10/26] pflash-cfi01: QOM'ify some more Hu Tao
2013-07-01 10:18 ` [Qemu-devel] [PATCH v2 11/26] pflash_cfi01: use realize for pflash_cfi01 Hu Tao
2013-07-01 10:18 ` [Qemu-devel] [PATCH v2 12/26] pflash-cfi02: QOM'ify some more Hu Tao
2013-07-01 10:18 ` [Qemu-devel] [PATCH v2 13/26] pflash_cfi02: use realize for pflash_cfi02 Hu Tao
2013-07-01 10:18 ` [Qemu-devel] [PATCH v2 14/26] ahci: QOM'ify some more Hu Tao
2013-07-01 10:18 ` [Qemu-devel] [PATCH v2 15/26] ahci: use realize for ahci Hu Tao
2013-07-21 9:13 ` Andreas Färber
2013-07-01 10:18 ` [Qemu-devel] [PATCH v2 16/26] fwcfg: QOM'ify some more Hu Tao
2013-07-01 10:18 ` [Qemu-devel] [PATCH v2 17/26] fwcfg: use realize for fwcfg Hu Tao
2013-07-21 9:35 ` Andreas Färber
2013-07-22 8:37 ` Hu Tao
2013-07-01 10:18 ` [Qemu-devel] [PATCH v2 18/26] scsi esp: QOM'ify some more Hu Tao
2013-07-01 10:18 ` [Qemu-devel] [PATCH v2 19/26] scsi esp: use realize for scsi esp Hu Tao
2013-07-21 9:47 ` Andreas Färber
2013-07-21 10:30 ` [Qemu-devel] [PATCH qom-next] scsi: Improve error propagation for scsi_bus_legacy_handle_cmdline() Andreas Färber
2013-07-22 9:16 ` Hu Tao
2013-07-22 10:24 ` Andreas Färber
2013-07-01 10:18 ` [Qemu-devel] [PATCH v2 20/26] hpet: QOM'ify some more Hu Tao
2013-07-01 10:18 ` [Qemu-devel] [PATCH v2 21/26] hpet: use realize for hpet Hu Tao
2013-07-01 10:18 ` [Qemu-devel] [PATCH v2 22/26] kvmclock: QOM'ify some more Hu Tao
2013-07-16 14:00 ` Andreas Färber
2013-07-01 10:18 ` [Qemu-devel] [PATCH v2 23/26] kvmclock: use realize for kvmclock Hu Tao
2013-07-01 10:18 ` [Qemu-devel] [PATCH v2 24/26] kvmvapic realize Hu Tao
2013-07-01 10:18 ` [Qemu-devel] [PATCH v2 25/26] ioapic: use realize for ioapic Hu Tao
2013-07-21 10:35 ` Andreas Färber
2013-07-01 10:18 ` [Qemu-devel] [PATCH v2 26/26] isa bus: remove isabus_bridge_init since it does nothing Hu Tao
2013-07-21 10:58 ` [Qemu-devel] [PATCH v2 00/26] use realizefn for SysBusDevice, part 1 Andreas Färber
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=51D9F41C.4000200@suse.de \
--to=afaerber@suse.de \
--cc=hutao@cn.fujitsu.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).