summaryrefslogtreecommitdiffstats
path: root/hw/pci-bridge/pci_expander_bridge.c
diff options
context:
space:
mode:
authorMarkus Armbruster2020-06-10 07:31:58 +0200
committerMarkus Armbruster2020-06-15 22:00:10 +0200
commit3e80f6902c13f6edb6675c0f33edcbbf0163ec32 (patch)
treec96a01def8de48a3fc1721bfe6344b9993bfaecf /hw/pci-bridge/pci_expander_bridge.c
parentqdev: Convert to qdev_unrealize() manually (diff)
downloadqemu-3e80f6902c13f6edb6675c0f33edcbbf0163ec32.tar.gz
qemu-3e80f6902c13f6edb6675c0f33edcbbf0163ec32.tar.xz
qemu-3e80f6902c13f6edb6675c0f33edcbbf0163ec32.zip
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]
Diffstat (limited to 'hw/pci-bridge/pci_expander_bridge.c')
-rw-r--r--hw/pci-bridge/pci_expander_bridge.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/hw/pci-bridge/pci_expander_bridge.c b/hw/pci-bridge/pci_expander_bridge.c
index 47aaaf8fd1..5da0d21061 100644
--- a/hw/pci-bridge/pci_expander_bridge.c
+++ b/hw/pci-bridge/pci_expander_bridge.c
@@ -231,7 +231,7 @@ static void pxb_dev_realize_common(PCIDevice *dev, bool pcie, Error **errp)
dev_name = dev->qdev.id;
}
- ds = qdev_create(NULL, TYPE_PXB_HOST);
+ ds = qdev_new(TYPE_PXB_HOST);
if (pcie) {
bus = pci_root_bus_new(ds, dev_name, NULL, NULL, 0, TYPE_PXB_PCIE_BUS);
} else {
@@ -255,7 +255,7 @@ static void pxb_dev_realize_common(PCIDevice *dev, bool pcie, Error **errp)
goto err_register_bus;
}
- qdev_init_nofail(ds);
+ qdev_realize_and_unref(ds, NULL, &error_fatal);
if (bds) {
qdev_init_nofail(bds);
}