mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 00:03:54 -06:00
pci: Convert uses of pci_create() etc. with Coccinelle
Replace dev = pci_create(bus, type_name); ... qdev_init_nofail(dev); by dev = pci_new(type_name); ... pci_realize_and_unref(dev, bus, &error_fatal); and similarly for pci_create_multifunction(). Recent commit "qdev: New qdev_new(), qdev_realize(), etc." explains why. Coccinelle script: @@ expression dev, bus, expr; expression list args; @@ - dev = pci_create(bus, args); + dev = pci_new(args); ... when != dev = expr - qdev_init_nofail(&dev->qdev); + pci_realize_and_unref(dev, bus, &error_fatal); @@ expression dev, bus, expr; expression list args; expression d; @@ - dev = pci_create(bus, args); + dev = pci_new(args); ( d = &dev->qdev; | d = DEVICE(dev); ) ... when != dev = expr - qdev_init_nofail(d); + pci_realize_and_unref(dev, bus, &error_fatal); @@ expression dev, bus, expr; expression list args; @@ - dev = pci_create(bus, args); + dev = pci_new(args); ... when != dev = expr - qdev_init_nofail(DEVICE(dev)); + pci_realize_and_unref(dev, bus, &error_fatal); @@ expression dev, bus, expr; expression list args; @@ - dev = DEVICE(pci_create(bus, args)); + PCIDevice *pci_dev; // TODO move + pci_dev = pci_new(args); + dev = DEVICE(pci_dev); ... when != dev = expr - qdev_init_nofail(dev); + pci_realize_and_unref(pci_dev, bus, &error_fatal); @@ expression dev, bus, expr; expression list args; @@ - dev = pci_create_multifunction(bus, args); + dev = pci_new_multifunction(args); ... when != dev = expr - qdev_init_nofail(&dev->qdev); + pci_realize_and_unref(dev, bus, &error_fatal); @@ expression bus, expr; expression list args; identifier dev; @@ - PCIDevice *dev = pci_create_multifunction(bus, args); + PCIDevice *dev = pci_new_multifunction(args); ... when != dev = expr - qdev_init_nofail(&dev->qdev); + pci_realize_and_unref(dev, bus, &error_fatal); @@ expression dev, bus, expr; expression list args; @@ - dev = pci_create_multifunction(bus, args); + dev = pci_new_multifunction(args); ... when != dev = expr - qdev_init_nofail(DEVICE(dev)); + pci_realize_and_unref(dev, bus, &error_fatal); Missing #include "qapi/error.h" added manually, whitespace changes minimized manually, @pci_dev declarations moved manually. Cc: Michael S. Tsirkin <mst@redhat.com> Cc: Marcel Apfelbaum <marcel.apfelbaum@gmail.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Message-Id: <20200610053247.1583243-16-armbru@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
7d61226158
commit
9307d06da9
11 changed files with 44 additions and 38 deletions
|
@ -750,11 +750,11 @@ PCIBus *bonito_init(qemu_irq *pic)
|
|||
pcihost->pic = pic;
|
||||
qdev_realize_and_unref(dev, NULL, &error_fatal);
|
||||
|
||||
d = pci_create(phb->bus, PCI_DEVFN(0, 0), TYPE_PCI_BONITO);
|
||||
d = pci_new(PCI_DEVFN(0, 0), TYPE_PCI_BONITO);
|
||||
s = PCI_BONITO(d);
|
||||
s->pcihost = pcihost;
|
||||
pcihost->pci_dev = s;
|
||||
qdev_init_nofail(DEVICE(d));
|
||||
pci_realize_and_unref(d, phb->bus, &error_fatal);
|
||||
|
||||
return phb->bus;
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "hw/pci-bridge/simba.h"
|
||||
#include "hw/pci-host/sabre.h"
|
||||
#include "exec/address-spaces.h"
|
||||
#include "qapi/error.h"
|
||||
#include "qemu/log.h"
|
||||
#include "qemu/module.h"
|
||||
#include "sysemu/runstate.h"
|
||||
|
@ -405,17 +406,17 @@ static void sabre_realize(DeviceState *dev, Error **errp)
|
|||
pci_setup_iommu(phb->bus, sabre_pci_dma_iommu, s->iommu);
|
||||
|
||||
/* APB secondary busses */
|
||||
pci_dev = pci_create_multifunction(phb->bus, PCI_DEVFN(1, 0), true,
|
||||
TYPE_SIMBA_PCI_BRIDGE);
|
||||
pci_dev = pci_new_multifunction(PCI_DEVFN(1, 0), true,
|
||||
TYPE_SIMBA_PCI_BRIDGE);
|
||||
s->bridgeB = PCI_BRIDGE(pci_dev);
|
||||
pci_bridge_map_irq(s->bridgeB, "pciB", pci_simbaB_map_irq);
|
||||
qdev_init_nofail(&pci_dev->qdev);
|
||||
pci_realize_and_unref(pci_dev, phb->bus, &error_fatal);
|
||||
|
||||
pci_dev = pci_create_multifunction(phb->bus, PCI_DEVFN(1, 1), true,
|
||||
TYPE_SIMBA_PCI_BRIDGE);
|
||||
pci_dev = pci_new_multifunction(PCI_DEVFN(1, 1), true,
|
||||
TYPE_SIMBA_PCI_BRIDGE);
|
||||
s->bridgeA = PCI_BRIDGE(pci_dev);
|
||||
pci_bridge_map_irq(s->bridgeA, "pciA", pci_simbaA_map_irq);
|
||||
qdev_init_nofail(&pci_dev->qdev);
|
||||
pci_realize_and_unref(pci_dev, phb->bus, &error_fatal);
|
||||
}
|
||||
|
||||
static void sabre_init(Object *obj)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue