diff mbox

[3/6] convert pci-host to QOM

Message ID 1332727608-26523-4-git-send-email-liwp@linux.vnet.ibm.com
State New
Headers show

Commit Message

Wanpeng Li March 26, 2012, 2:06 a.m. UTC
From: Anthony Liguori <aliguori@us.ibm.com>


Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Wanpeng Li <liwp@linux.vnet.ibm.com>

---
 hw/pci_host.c |   26 ++++++++++++++++++++++++++
 hw/pci_host.h |    5 +++++
 2 files changed, 31 insertions(+), 0 deletions(-)

Comments

Stefan Hajnoczi March 26, 2012, 7:32 a.m. UTC | #1
On Mon, Mar 26, 2012 at 10:06:45AM +0800, Wanpeng Li wrote:
> diff --git a/hw/pci_host.c b/hw/pci_host.c
> index 44c6c20..44d7e55 100644
> --- a/hw/pci_host.c
> +++ b/hw/pci_host.c
> @@ -162,4 +162,30 @@ const MemoryRegionOps pci_host_data_be_ops = {
>      .endianness = DEVICE_BIG_ENDIAN,
>  };
>  
> +void pci_host_set_mmio(PCIHostState *s, MemoryRegion *value)
> +{
> +	object_property_set_link(OBJECT(s), OBJECT(value), "mmio", NULL);
> +}
> +
> +static void pci_host_initfn(Object *obj)
> +{
> +    PCIHostState *s = PCI_HOST(obj);
> +
> +	object_property_add_link(obj, "mmio", TYPE_MEMORY_REGION,
> +					         (Object **)&s->address_space, NULL);

This patch has tabs instead of 4-space indent.
Andreas Färber March 26, 2012, 2:25 p.m. UTC | #2
Am 26.03.2012 04:06, schrieb Wanpeng Li:
> From: Anthony Liguori <aliguori@us.ibm.com>
> 
> 
> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
> Signed-off-by: Wanpeng Li <liwp@linux.vnet.ibm.com>

Some minor formal comments inline, otherwise looks okay.

> ---
>  hw/pci_host.c |   26 ++++++++++++++++++++++++++
>  hw/pci_host.h |    5 +++++
>  2 files changed, 31 insertions(+), 0 deletions(-)
> 
> diff --git a/hw/pci_host.c b/hw/pci_host.c
> index 44c6c20..44d7e55 100644
> --- a/hw/pci_host.c
> +++ b/hw/pci_host.c
> @@ -162,4 +162,30 @@ const MemoryRegionOps pci_host_data_be_ops = {
>      .endianness = DEVICE_BIG_ENDIAN,
>  };
>  
> +void pci_host_set_mmio(PCIHostState *s, MemoryRegion *value)
> +{
> +	object_property_set_link(OBJECT(s), OBJECT(value), "mmio", NULL);
> +}
> +
> +static void pci_host_initfn(Object *obj)
> +{
> +    PCIHostState *s = PCI_HOST(obj);
> +
> +	object_property_add_link(obj, "mmio", TYPE_MEMORY_REGION,
> +					         (Object **)&s->address_space, NULL);
> +}
> +
> +static TypeInfo pci_host_type = {

I thought the convention was ..._type_info (in case we ever need to do a
mass conversion again). And please make it static const.

> +    .name = TYPE_PCI_HOST,
> +    .parent = TYPE_SYS_BUS_DEVICE,
> +	.instance_size = sizeof(PCIHostState),
> +	.instance_init = pci_host_initfn,
> +};
> +
> +static void register_devices(void)

pci_host_register_types please.

> +{
> +	type_register_static(&pci_host_type);
> +}
> +
> +type_init(register_devices);

No semicolon please, it's not a statement.

There's still some tabs left in the revised version, please run
script/checkpatch.pl and repost a v3 inline so that we can comment on it.

Andreas
diff mbox

Patch

diff --git a/hw/pci_host.c b/hw/pci_host.c
index 44c6c20..44d7e55 100644
--- a/hw/pci_host.c
+++ b/hw/pci_host.c
@@ -162,4 +162,30 @@  const MemoryRegionOps pci_host_data_be_ops = {
     .endianness = DEVICE_BIG_ENDIAN,
 };
 
+void pci_host_set_mmio(PCIHostState *s, MemoryRegion *value)
+{
+	object_property_set_link(OBJECT(s), OBJECT(value), "mmio", NULL);
+}
+
+static void pci_host_initfn(Object *obj)
+{
+    PCIHostState *s = PCI_HOST(obj);
+
+	object_property_add_link(obj, "mmio", TYPE_MEMORY_REGION,
+					         (Object **)&s->address_space, NULL);
+}
+
+static TypeInfo pci_host_type = {
+    .name = TYPE_PCI_HOST,
+    .parent = TYPE_SYS_BUS_DEVICE,
+	.instance_size = sizeof(PCIHostState),
+	.instance_init = pci_host_initfn,
+};
+
+static void register_devices(void)
+{
+	type_register_static(&pci_host_type);
+}
+
+type_init(register_devices);
 
diff --git a/hw/pci_host.h b/hw/pci_host.h
index 359e38f..084e15c 100644
--- a/hw/pci_host.h
+++ b/hw/pci_host.h
@@ -30,6 +30,9 @@ 
 
 #include "sysbus.h"
 
+#define TYPE_PCI_HOST "pci-host"
+#define PCI_HOST(obj) OBJECT_CHECK(PCIHostState, (obj), TYPE_PCI_HOST)
+
 struct PCIHostState {
     SysBusDevice busdev;
     MemoryRegion conf_mem;
@@ -49,6 +52,8 @@  uint32_t pci_host_config_read_common(PCIDevice *pci_dev, uint32_t addr,
 void pci_data_write(PCIBus *s, uint32_t addr, uint32_t val, int len);
 uint32_t pci_data_read(PCIBus *s, uint32_t addr, int len);
 
+void pci_host_set_mmio(PCIHostState *s, MemoryRegion *value);
+
 extern const MemoryRegionOps pci_host_conf_le_ops;
 extern const MemoryRegionOps pci_host_conf_be_ops;
 extern const MemoryRegionOps pci_host_data_le_ops;