aboutsummaryrefslogtreecommitdiff
path: root/hw/mips
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2020-06-10 07:31:58 +0200
committerMarkus Armbruster <armbru@redhat.com>2020-06-15 22:00:10 +0200
commit3e80f6902c13f6edb6675c0f33edcbbf0163ec32 (patch)
treec96a01def8de48a3fc1721bfe6344b9993bfaecf /hw/mips
parentdc3edf8d8a544dbf21e1cb63339e42806470d5d9 (diff)
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/mips')
-rw-r--r--hw/mips/boston.c8
-rw-r--r--hw/mips/gt64xxx_pci.c5
-rw-r--r--hw/mips/jazz.c16
-rw-r--r--hw/mips/malta.c4
-rw-r--r--hw/mips/mipssim.c8
5 files changed, 21 insertions, 20 deletions
diff --git a/hw/mips/boston.c b/hw/mips/boston.c
index a896056be1..a34ccdf616 100644
--- a/hw/mips/boston.c
+++ b/hw/mips/boston.c
@@ -400,7 +400,7 @@ xilinx_pcie_init(MemoryRegion *sys_mem, uint32_t bus_nr,
DeviceState *dev;
MemoryRegion *cfg, *mmio;
- dev = qdev_create(NULL, TYPE_XILINX_PCIE_HOST);
+ dev = qdev_new(TYPE_XILINX_PCIE_HOST);
qdev_prop_set_uint32(dev, "bus_nr", bus_nr);
qdev_prop_set_uint64(dev, "cfg_base", cfg_base);
@@ -409,7 +409,7 @@ xilinx_pcie_init(MemoryRegion *sys_mem, uint32_t bus_nr,
qdev_prop_set_uint64(dev, "mmio_size", mmio_size);
qdev_prop_set_bit(dev, "link_up", link_up);
- qdev_init_nofail(dev);
+ qdev_realize_and_unref(dev, NULL, &error_fatal);
cfg = sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 0);
memory_region_add_subregion_overlap(sys_mem, cfg_base, cfg, 0);
@@ -441,8 +441,8 @@ static void boston_mach_init(MachineState *machine)
exit(1);
}
- dev = qdev_create(NULL, TYPE_MIPS_BOSTON);
- qdev_init_nofail(dev);
+ dev = qdev_new(TYPE_MIPS_BOSTON);
+ qdev_realize_and_unref(dev, NULL, &error_fatal);
s = BOSTON(dev);
s->mach = machine;
diff --git a/hw/mips/gt64xxx_pci.c b/hw/mips/gt64xxx_pci.c
index b2ea13f09d..37750b8037 100644
--- a/hw/mips/gt64xxx_pci.c
+++ b/hw/mips/gt64xxx_pci.c
@@ -23,6 +23,7 @@
*/
#include "qemu/osdep.h"
+#include "qapi/error.h"
#include "qemu/units.h"
#include "qemu/log.h"
#include "hw/mips/mips.h"
@@ -1201,7 +1202,7 @@ PCIBus *gt64120_register(qemu_irq *pic)
PCIHostState *phb;
DeviceState *dev;
- dev = qdev_create(NULL, TYPE_GT64120_PCI_HOST_BRIDGE);
+ dev = qdev_new(TYPE_GT64120_PCI_HOST_BRIDGE);
d = GT64120_PCI_HOST_BRIDGE(dev);
phb = PCI_HOST_BRIDGE(dev);
memory_region_init(&d->pci0_mem, OBJECT(dev), "pci0-mem", 4 * GiB);
@@ -1212,7 +1213,7 @@ PCIBus *gt64120_register(qemu_irq *pic)
&d->pci0_mem,
get_system_io(),
PCI_DEVFN(18, 0), 4, TYPE_PCI_BUS);
- qdev_init_nofail(dev);
+ qdev_realize_and_unref(dev, NULL, &error_fatal);
memory_region_init_io(&d->ISD_mem, OBJECT(dev), &isd_mem_ops, d,
"isd-mem", 0x1000);
diff --git a/hw/mips/jazz.c b/hw/mips/jazz.c
index afea52b41b..fb975bd1c7 100644
--- a/hw/mips/jazz.c
+++ b/hw/mips/jazz.c
@@ -255,8 +255,8 @@ static void mips_jazz_init(MachineState *machine,
/* Video card */
switch (jazz_model) {
case JAZZ_MAGNUM:
- dev = qdev_create(NULL, "sysbus-g364");
- qdev_init_nofail(dev);
+ dev = qdev_new("sysbus-g364");
+ qdev_realize_and_unref(dev, NULL, &error_fatal);
sysbus = SYS_BUS_DEVICE(dev);
sysbus_mmio_map(sysbus, 0, 0x60080000);
sysbus_mmio_map(sysbus, 1, 0x40000000);
@@ -287,12 +287,12 @@ static void mips_jazz_init(MachineState *machine,
if (strcmp(nd->model, "dp83932") == 0) {
qemu_check_nic_model(nd, "dp83932");
- dev = qdev_create(NULL, "dp8393x");
+ dev = qdev_new("dp8393x");
qdev_set_nic_properties(dev, nd);
qdev_prop_set_uint8(dev, "it_shift", 2);
object_property_set_link(OBJECT(dev), OBJECT(rc4030_dma_mr),
"dma_mr", &error_abort);
- qdev_init_nofail(dev);
+ qdev_realize_and_unref(dev, NULL, &error_fatal);
sysbus = SYS_BUS_DEVICE(dev);
sysbus_mmio_map(sysbus, 0, 0x80001000);
sysbus_mmio_map(sysbus, 1, 0x8000b000);
@@ -308,7 +308,7 @@ static void mips_jazz_init(MachineState *machine,
}
/* SCSI adapter */
- dev = qdev_create(NULL, TYPE_ESP);
+ dev = qdev_new(TYPE_ESP);
sysbus_esp = ESP_STATE(dev);
esp = &sysbus_esp->esp;
esp->dma_memory_read = rc4030_dma_read;
@@ -317,7 +317,7 @@ static void mips_jazz_init(MachineState *machine,
sysbus_esp->it_shift = 0;
/* XXX for now until rc4030 has been changed to use DMA enable signal */
esp->dma_enabled = 1;
- qdev_init_nofail(dev);
+ qdev_realize_and_unref(dev, NULL, &error_fatal);
sysbus = SYS_BUS_DEVICE(dev);
sysbus_connect_irq(sysbus, 0, qdev_get_gpio_in(rc4030, 5));
@@ -362,8 +362,8 @@ static void mips_jazz_init(MachineState *machine,
/* FIXME: missing Jazz sound at 0x8000c000, rc4030[2] */
/* NVRAM */
- dev = qdev_create(NULL, "ds1225y");
- qdev_init_nofail(dev);
+ dev = qdev_new("ds1225y");
+ qdev_realize_and_unref(dev, NULL, &error_fatal);
sysbus = SYS_BUS_DEVICE(dev);
sysbus_mmio_map(sysbus, 0, 0x80009000);
diff --git a/hw/mips/malta.c b/hw/mips/malta.c
index 62063b2305..cfc236a1da 100644
--- a/hw/mips/malta.c
+++ b/hw/mips/malta.c
@@ -1233,7 +1233,7 @@ void mips_malta_init(MachineState *machine)
int fl_idx = 0;
int be;
- DeviceState *dev = qdev_create(NULL, TYPE_MIPS_MALTA);
+ DeviceState *dev = qdev_new(TYPE_MIPS_MALTA);
MaltaState *s = MIPS_MALTA(dev);
/*
@@ -1243,7 +1243,7 @@ void mips_malta_init(MachineState *machine)
*/
empty_slot_init("GT64120", 0, 0x20000000);
- qdev_init_nofail(dev);
+ qdev_realize_and_unref(dev, NULL, &error_fatal);
/* create CPU */
mips_create_cpu(machine, s, &cbus_irq, &i8259_irq);
diff --git a/hw/mips/mipssim.c b/hw/mips/mipssim.c
index d220318939..72b1e846af 100644
--- a/hw/mips/mipssim.c
+++ b/hw/mips/mipssim.c
@@ -129,9 +129,9 @@ static void mipsnet_init(int base, qemu_irq irq, NICInfo *nd)
DeviceState *dev;
SysBusDevice *s;
- dev = qdev_create(NULL, "mipsnet");
+ dev = qdev_new("mipsnet");
qdev_set_nic_properties(dev, nd);
- qdev_init_nofail(dev);
+ qdev_realize_and_unref(dev, NULL, &error_fatal);
s = SYS_BUS_DEVICE(dev);
sysbus_connect_irq(s, 0, irq);
@@ -216,11 +216,11 @@ mips_mipssim_init(MachineState *machine)
* MIPS CPU INT2, which is interrupt 4.
*/
if (serial_hd(0)) {
- DeviceState *dev = qdev_create(NULL, TYPE_SERIAL_IO);
+ DeviceState *dev = qdev_new(TYPE_SERIAL_IO);
qdev_prop_set_chr(dev, "chardev", serial_hd(0));
qdev_set_legacy_instance_id(dev, 0x3f8, 2);
- qdev_init_nofail(dev);
+ qdev_realize_and_unref(dev, NULL, &error_fatal);
sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, env->irq[4]);
sysbus_add_io(SYS_BUS_DEVICE(dev), 0x3f8,
sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 0));