Message ID | 20181001220942.2382-7-f4bug@amsat.org |
---|---|
State | New |
Headers | show |
Series | another SysBusDevice::init to Device::realize cleanup | expand |
On 10/2/18 12:09 AM, Philippe Mathieu-Daudé wrote: > Move from the legacy SysBusDevice::init method to using DeviceState::realize. > > Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> > --- > hw/pci-host/bonito.c | 9 +++------ > 1 file changed, 3 insertions(+), 6 deletions(-) > > diff --git a/hw/pci-host/bonito.c b/hw/pci-host/bonito.c > index 9868e2eccc..03d1ec33e3 100644 > --- a/hw/pci-host/bonito.c > +++ b/hw/pci-host/bonito.c > @@ -595,7 +595,7 @@ static const VMStateDescription vmstate_bonito = { > } > }; > > -static int bonito_pcihost_initfn(SysBusDevice *dev) > +static void bonito_pcihost_realize(PCIDevice *dev, Error **errp) This patch is incorrect, see: https://lists.gnu.org/archive/html/qemu-devel/2018-10/msg00378.html > { > PCIHostState *phb = PCI_HOST_BRIDGE(dev); > > @@ -603,8 +603,6 @@ static int bonito_pcihost_initfn(SysBusDevice *dev) > pci_bonito_set_irq, pci_bonito_map_irq, > dev, get_system_memory(), get_system_io(), > 0x28, 32, TYPE_PCI_BUS); > - > - return 0; > } > > static void bonito_realize(PCIDevice *dev, Error **errp) > @@ -684,7 +682,6 @@ PCIBus *bonito_init(qemu_irq *pic) > pcihost->pic = pic; > qdev_init_nofail(dev); > > - /* set the pcihost pointer before bonito_initfn is called */ > d = pci_create(phb->bus, PCI_DEVFN(0, 0), TYPE_PCI_BONITO); > s = PCI_BONITO(d); > s->pcihost = pcihost; > @@ -726,9 +723,9 @@ static const TypeInfo bonito_info = { > > static void bonito_pcihost_class_init(ObjectClass *klass, void *data) > { > - SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); > + PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); > > - k->init = bonito_pcihost_initfn; > + k->realize = bonito_pcihost_realize; > } > > static const TypeInfo bonito_pcihost_info = { >
diff --git a/hw/pci-host/bonito.c b/hw/pci-host/bonito.c index 9868e2eccc..03d1ec33e3 100644 --- a/hw/pci-host/bonito.c +++ b/hw/pci-host/bonito.c @@ -595,7 +595,7 @@ static const VMStateDescription vmstate_bonito = { } }; -static int bonito_pcihost_initfn(SysBusDevice *dev) +static void bonito_pcihost_realize(PCIDevice *dev, Error **errp) { PCIHostState *phb = PCI_HOST_BRIDGE(dev); @@ -603,8 +603,6 @@ static int bonito_pcihost_initfn(SysBusDevice *dev) pci_bonito_set_irq, pci_bonito_map_irq, dev, get_system_memory(), get_system_io(), 0x28, 32, TYPE_PCI_BUS); - - return 0; } static void bonito_realize(PCIDevice *dev, Error **errp) @@ -684,7 +682,6 @@ PCIBus *bonito_init(qemu_irq *pic) pcihost->pic = pic; qdev_init_nofail(dev); - /* set the pcihost pointer before bonito_initfn is called */ d = pci_create(phb->bus, PCI_DEVFN(0, 0), TYPE_PCI_BONITO); s = PCI_BONITO(d); s->pcihost = pcihost; @@ -726,9 +723,9 @@ static const TypeInfo bonito_info = { static void bonito_pcihost_class_init(ObjectClass *klass, void *data) { - SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); + PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); - k->init = bonito_pcihost_initfn; + k->realize = bonito_pcihost_realize; } static const TypeInfo bonito_pcihost_info = {
Move from the legacy SysBusDevice::init method to using DeviceState::realize. Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> --- hw/pci-host/bonito.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)