Hi, Philippe

On 11/24/18 12:37 AM, Philippe Mathieu-Daudé wrote:
Hi Mao,

On 23/11/18 16:30, Mao Zhongyi wrote:
Use DeviceClass rather than SysBusDeviceClass in
pci_dec_21154_device_class_init().

Cc: da...@gibson.dropbear.id.au
Cc: m...@redhat.com
Cc: marcel.apfelb...@gmail.com
Cc: qemu-...@nongnu.org

Signed-off-by: Mao Zhongyi <maozhon...@cmss.chinamobile.com>
Signed-off-by: Zhang Shengju <zhangshen...@cmss.chinamobile.com>
Reviewed-by: David Gibson <da...@gibson.dropbear.id.au>
Acked-by: David Gibson <da...@gibson.dropbear.id.au>
---
  hw/pci-bridge/dec.c | 11 +++++------
  1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/hw/pci-bridge/dec.c b/hw/pci-bridge/dec.c
index 84492d5e5f..5b21c20e50 100644
--- a/hw/pci-bridge/dec.c
+++ b/hw/pci-bridge/dec.c
@@ -98,7 +98,7 @@ PCIBus *pci_dec_21154_init(PCIBus *parent_bus, int devfn)
      return pci_bridge_get_sec_bus(br);
  }
-static int pci_dec_21154_device_init(SysBusDevice *dev)
+static void pci_dec_21154_device_realize(DeviceState *dev, Error **errp)
  {
      PCIHostState *phb;

Why don't you use:

        SysBusDevice *sbd = SYS_BUS_DEVICE(dev);

like in all the other patches from this series...?

Oops, sorry, I missed this one, will fix it in v3.

Thanks,
Mao


@@ -108,9 +108,8 @@ static int pci_dec_21154_device_init(SysBusDevice *dev)
                            dev, "pci-conf-idx", 0x1000);
      memory_region_init_io(&phb->data_mem, OBJECT(dev), &pci_host_data_le_ops,
                            dev, "pci-data-idx", 0x1000);
-    sysbus_init_mmio(dev, &phb->conf_mem);
-    sysbus_init_mmio(dev, &phb->data_mem);
-    return 0;
+    sysbus_init_mmio(SYS_BUS_DEVICE(dev), &phb->conf_mem);
+    sysbus_init_mmio(SYS_BUS_DEVICE(dev), &phb->data_mem);

... this would save extra type checking here, as explain by Peter:
https://lists.gnu.org/archive/html/qemu-devel/2018-11/msg03644.html

  }
static void dec_21154_pci_host_realize(PCIDevice *d, Error **errp)
@@ -150,9 +149,9 @@ static const TypeInfo dec_21154_pci_host_info = {
static void pci_dec_21154_device_class_init(ObjectClass *klass, void *data)
  {
-    SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass);
+    DeviceClass *dc = DEVICE_CLASS(klass);
- sdc->init = pci_dec_21154_device_init;
+    dc->realize = pci_dec_21154_device_realize;
  }
static const TypeInfo pci_dec_21154_device_info = {





Reply via email to