mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 00:03:54 -06:00
qdev: Convert uses of qdev_create() with Coccinelle
This is the transformation explained in the commit before previous. Takes care of just one pattern that needs conversion. More to come in this series. Coccinelle script: @ depends on !(file in "hw/arm/highbank.c")@ expression bus, type_name, dev, expr; @@ - dev = qdev_create(bus, type_name); + dev = qdev_new(type_name); ... when != dev = expr - qdev_init_nofail(dev); + qdev_realize_and_unref(dev, bus, &error_fatal); @@ expression bus, type_name, dev, expr; identifier DOWN; @@ - dev = DOWN(qdev_create(bus, type_name)); + dev = DOWN(qdev_new(type_name)); ... when != dev = expr - qdev_init_nofail(DEVICE(dev)); + qdev_realize_and_unref(DEVICE(dev), bus, &error_fatal); @@ expression bus, type_name, expr; identifier dev; @@ - DeviceState *dev = qdev_create(bus, type_name); + DeviceState *dev = qdev_new(type_name); ... when != dev = expr - qdev_init_nofail(dev); + qdev_realize_and_unref(dev, bus, &error_fatal); @@ expression bus, type_name, dev, expr, errp; symbol true; @@ - dev = qdev_create(bus, type_name); + dev = qdev_new(type_name); ... when != dev = expr - object_property_set_bool(OBJECT(dev), true, "realized", errp); + qdev_realize_and_unref(dev, bus, errp); @@ expression bus, type_name, expr, errp; identifier dev; symbol true; @@ - DeviceState *dev = qdev_create(bus, type_name); + DeviceState *dev = qdev_new(type_name); ... when != dev = expr - object_property_set_bool(OBJECT(dev), true, "realized", errp); + qdev_realize_and_unref(dev, bus, errp); The first rule exempts hw/arm/highbank.c, because it matches along two control flow paths there, with different @type_name. Covered by the next commit's manual conversions. Missing #include "qapi/error.h" added manually. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Message-Id: <20200610053247.1583243-10-armbru@redhat.com> [Conflicts in hw/misc/empty_slot.c and hw/sparc/leon3.c resolved]
This commit is contained in:
parent
dc3edf8d8a
commit
3e80f6902c
127 changed files with 581 additions and 552 deletions
|
@ -40,6 +40,7 @@
|
|||
|
||||
#include "qemu/osdep.h"
|
||||
#include "qemu/units.h"
|
||||
#include "qapi/error.h"
|
||||
#include "qemu/error-report.h"
|
||||
#include "hw/pci/pci.h"
|
||||
#include "hw/irq.h"
|
||||
|
@ -743,11 +744,11 @@ PCIBus *bonito_init(qemu_irq *pic)
|
|||
PCIBonitoState *s;
|
||||
PCIDevice *d;
|
||||
|
||||
dev = qdev_create(NULL, TYPE_BONITO_PCI_HOST_BRIDGE);
|
||||
dev = qdev_new(TYPE_BONITO_PCI_HOST_BRIDGE);
|
||||
phb = PCI_HOST_BRIDGE(dev);
|
||||
pcihost = BONITO_PCI_HOST_BRIDGE(dev);
|
||||
pcihost->pic = pic;
|
||||
qdev_init_nofail(dev);
|
||||
qdev_realize_and_unref(dev, NULL, &error_fatal);
|
||||
|
||||
d = pci_create(phb->bus, PCI_DEVFN(0, 0), TYPE_PCI_BONITO);
|
||||
s = PCI_BONITO(d);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue