isa: Convert uses of isa_create() with Coccinelle
Replace dev = isa_create(bus, type_name); ... qdev_init_nofail(dev); by dev = isa_new(type_name); ... isa_realize_and_unref(dev, bus, &error_fatal); Recent commit "qdev: New qdev_new(), qdev_realize(), etc." explains why. Coccinelle script: @@ expression dev, bus, expr; expression list args; expression d; @@ - dev = isa_create(bus, args); + dev = isa_new(args); ( d = &dev->qdev; | d = DEVICE(dev); ) ... when != dev = expr - qdev_init_nofail(d); + isa_realize_and_unref(dev, bus, &error_fatal); @@ expression dev, bus, expr; expression list args; @@ - dev = isa_create(bus, args); + dev = isa_new(args); ... when != dev = expr - qdev_init_nofail(DEVICE(dev)); + isa_realize_and_unref(dev, bus, &error_fatal); @@ expression dev, bus, expr; expression list args; @@ - dev = DEVICE(isa_create(bus, args)); + ISADevice *isa_dev; // TODO move + isa_dev = isa_new(args); + dev = DEVICE(isa_dev); ... when != dev = expr - qdev_init_nofail(dev); + isa_realize_and_unref(isa_dev, bus, &error_fatal); Missing #include "qapi/error.h" added manually, whitespace changes minimized manually. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Message-Id: <20200610053247.1583243-20-armbru@redhat.com>
This commit is contained in:
parent
0fe9d90119
commit
96927c744f
@ -14,17 +14,18 @@
|
||||
#include "hw/isa/isa.h"
|
||||
#include "hw/qdev-properties.h"
|
||||
#include "hw/char/parallel.h"
|
||||
#include "qapi/error.h"
|
||||
|
||||
static void parallel_init(ISABus *bus, int index, Chardev *chr)
|
||||
{
|
||||
DeviceState *dev;
|
||||
ISADevice *isadev;
|
||||
|
||||
isadev = isa_create(bus, "isa-parallel");
|
||||
isadev = isa_new("isa-parallel");
|
||||
dev = DEVICE(isadev);
|
||||
qdev_prop_set_uint32(dev, "index", index);
|
||||
qdev_prop_set_chr(dev, "chardev", chr);
|
||||
qdev_init_nofail(dev);
|
||||
isa_realize_and_unref(isadev, bus, &error_fatal);
|
||||
}
|
||||
|
||||
void parallel_hds_isa_init(ISABus *bus, int n)
|
||||
|
@ -160,11 +160,11 @@ static void serial_isa_init(ISABus *bus, int index, Chardev *chr)
|
||||
DeviceState *dev;
|
||||
ISADevice *isadev;
|
||||
|
||||
isadev = isa_create(bus, TYPE_ISA_SERIAL);
|
||||
isadev = isa_new(TYPE_ISA_SERIAL);
|
||||
dev = DEVICE(isadev);
|
||||
qdev_prop_set_uint32(dev, "index", index);
|
||||
qdev_prop_set_chr(dev, "chardev", chr);
|
||||
qdev_init_nofail(dev);
|
||||
isa_realize_and_unref(isadev, bus, &error_fatal);
|
||||
}
|
||||
|
||||
void serial_hds_isa_init(ISABus *bus, int from, int to)
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "hw/qdev-properties.h"
|
||||
#include "migration/vmstate.h"
|
||||
#include "hw/dma/i8257.h"
|
||||
#include "qapi/error.h"
|
||||
#include "qemu/main-loop.h"
|
||||
#include "qemu/module.h"
|
||||
#include "qemu/log.h"
|
||||
@ -638,21 +639,21 @@ void i8257_dma_init(ISABus *bus, bool high_page_enable)
|
||||
ISADevice *isa1, *isa2;
|
||||
DeviceState *d;
|
||||
|
||||
isa1 = isa_create(bus, TYPE_I8257);
|
||||
isa1 = isa_new(TYPE_I8257);
|
||||
d = DEVICE(isa1);
|
||||
qdev_prop_set_int32(d, "base", 0x00);
|
||||
qdev_prop_set_int32(d, "page-base", 0x80);
|
||||
qdev_prop_set_int32(d, "pageh-base", high_page_enable ? 0x480 : -1);
|
||||
qdev_prop_set_int32(d, "dshift", 0);
|
||||
qdev_init_nofail(d);
|
||||
isa_realize_and_unref(isa1, bus, &error_fatal);
|
||||
|
||||
isa2 = isa_create(bus, TYPE_I8257);
|
||||
isa2 = isa_new(TYPE_I8257);
|
||||
d = DEVICE(isa2);
|
||||
qdev_prop_set_int32(d, "base", 0xc0);
|
||||
qdev_prop_set_int32(d, "page-base", 0x88);
|
||||
qdev_prop_set_int32(d, "pageh-base", high_page_enable ? 0x488 : -1);
|
||||
qdev_prop_set_int32(d, "dshift", 1);
|
||||
qdev_init_nofail(d);
|
||||
isa_realize_and_unref(isa2, bus, &error_fatal);
|
||||
|
||||
isa_bus_dma(bus, ISADMA(isa1), ISADMA(isa2));
|
||||
}
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "hw/isa/isa.h"
|
||||
#include "hw/qdev-properties.h"
|
||||
#include "migration/vmstate.h"
|
||||
#include "qapi/error.h"
|
||||
#include "qemu/module.h"
|
||||
#include "sysemu/dma.h"
|
||||
|
||||
@ -86,12 +87,12 @@ ISADevice *isa_ide_init(ISABus *bus, int iobase, int iobase2, int isairq,
|
||||
ISADevice *isadev;
|
||||
ISAIDEState *s;
|
||||
|
||||
isadev = isa_create(bus, TYPE_ISA_IDE);
|
||||
isadev = isa_new(TYPE_ISA_IDE);
|
||||
dev = DEVICE(isadev);
|
||||
qdev_prop_set_uint32(dev, "iobase", iobase);
|
||||
qdev_prop_set_uint32(dev, "iobase2", iobase2);
|
||||
qdev_prop_set_uint32(dev, "irq", isairq);
|
||||
qdev_init_nofail(dev);
|
||||
isa_realize_and_unref(isadev, bus, &error_fatal);
|
||||
|
||||
s = ISA_IDE(dev);
|
||||
if (hd0) {
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "hw/qdev-properties.h"
|
||||
#include "migration/vmstate.h"
|
||||
#include "monitor/monitor.h"
|
||||
#include "qapi/error.h"
|
||||
|
||||
static int irq_level[16];
|
||||
static uint64_t irq_count[16];
|
||||
@ -94,13 +95,13 @@ ISADevice *i8259_init_chip(const char *name, ISABus *bus, bool master)
|
||||
DeviceState *dev;
|
||||
ISADevice *isadev;
|
||||
|
||||
isadev = isa_create(bus, name);
|
||||
isadev = isa_new(name);
|
||||
dev = DEVICE(isadev);
|
||||
qdev_prop_set_uint32(dev, "iobase", master ? 0x20 : 0xa0);
|
||||
qdev_prop_set_uint32(dev, "elcr_addr", master ? 0x4d0 : 0x4d1);
|
||||
qdev_prop_set_uint8(dev, "elcr_mask", master ? 0xf8 : 0xde);
|
||||
qdev_prop_set_bit(dev, "master", master);
|
||||
qdev_init_nofail(dev);
|
||||
isa_realize_and_unref(isadev, bus, &error_fatal);
|
||||
|
||||
return isadev;
|
||||
}
|
||||
|
@ -190,8 +190,8 @@ ISADevice *isa_create_simple(ISABus *bus, const char *name)
|
||||
{
|
||||
ISADevice *dev;
|
||||
|
||||
dev = isa_create(bus, name);
|
||||
qdev_init_nofail(DEVICE(dev));
|
||||
dev = isa_new(name);
|
||||
isa_realize_and_unref(dev, bus, &error_fatal);
|
||||
return dev;
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ static void isa_superio_realize(DeviceState *dev, Error **errp)
|
||||
} else {
|
||||
name = g_strdup_printf("parallel%d", i);
|
||||
}
|
||||
isa = isa_create(bus, "isa-parallel");
|
||||
isa = isa_new("isa-parallel");
|
||||
d = DEVICE(isa);
|
||||
qdev_prop_set_uint32(d, "index", i);
|
||||
if (k->parallel.get_iobase) {
|
||||
@ -63,7 +63,7 @@ static void isa_superio_realize(DeviceState *dev, Error **errp)
|
||||
}
|
||||
qdev_prop_set_chr(d, "chardev", chr);
|
||||
object_property_add_child(OBJECT(dev), name, OBJECT(isa));
|
||||
qdev_init_nofail(d);
|
||||
isa_realize_and_unref(isa, bus, &error_fatal);
|
||||
sio->parallel[i] = isa;
|
||||
trace_superio_create_parallel(i,
|
||||
k->parallel.get_iobase ?
|
||||
@ -90,7 +90,7 @@ static void isa_superio_realize(DeviceState *dev, Error **errp)
|
||||
} else {
|
||||
name = g_strdup_printf("serial%d", i);
|
||||
}
|
||||
isa = isa_create(bus, TYPE_ISA_SERIAL);
|
||||
isa = isa_new(TYPE_ISA_SERIAL);
|
||||
d = DEVICE(isa);
|
||||
qdev_prop_set_uint32(d, "index", i);
|
||||
if (k->serial.get_iobase) {
|
||||
@ -102,7 +102,7 @@ static void isa_superio_realize(DeviceState *dev, Error **errp)
|
||||
}
|
||||
qdev_prop_set_chr(d, "chardev", chr);
|
||||
object_property_add_child(OBJECT(dev), name, OBJECT(isa));
|
||||
qdev_init_nofail(d);
|
||||
isa_realize_and_unref(isa, bus, &error_fatal);
|
||||
sio->serial[i] = isa;
|
||||
trace_superio_create_serial(i,
|
||||
k->serial.get_iobase ?
|
||||
@ -115,7 +115,7 @@ static void isa_superio_realize(DeviceState *dev, Error **errp)
|
||||
|
||||
/* Floppy disc */
|
||||
if (!k->floppy.is_enabled || k->floppy.is_enabled(sio, 0)) {
|
||||
isa = isa_create(bus, "isa-fdc");
|
||||
isa = isa_new("isa-fdc");
|
||||
d = DEVICE(isa);
|
||||
if (k->floppy.get_iobase) {
|
||||
qdev_prop_set_uint32(d, "iobase", k->floppy.get_iobase(sio, 0));
|
||||
@ -136,7 +136,7 @@ static void isa_superio_realize(DeviceState *dev, Error **errp)
|
||||
&error_fatal);
|
||||
}
|
||||
object_property_add_child(OBJECT(sio), "isa-fdc", OBJECT(isa));
|
||||
qdev_init_nofail(d);
|
||||
isa_realize_and_unref(isa, bus, &error_fatal);
|
||||
sio->floppy = isa;
|
||||
trace_superio_create_floppy(0,
|
||||
k->floppy.get_iobase ?
|
||||
@ -146,14 +146,14 @@ static void isa_superio_realize(DeviceState *dev, Error **errp)
|
||||
}
|
||||
|
||||
/* Keyboard, mouse */
|
||||
isa = isa_create(bus, TYPE_I8042);
|
||||
isa = isa_new(TYPE_I8042);
|
||||
object_property_add_child(OBJECT(sio), TYPE_I8042, OBJECT(isa));
|
||||
qdev_init_nofail(DEVICE(isa));
|
||||
isa_realize_and_unref(isa, bus, &error_fatal);
|
||||
sio->kbc = isa;
|
||||
|
||||
/* IDE */
|
||||
if (k->ide.count && (!k->ide.is_enabled || k->ide.is_enabled(sio, 0))) {
|
||||
isa = isa_create(bus, "isa-ide");
|
||||
isa = isa_new("isa-ide");
|
||||
d = DEVICE(isa);
|
||||
if (k->ide.get_iobase) {
|
||||
qdev_prop_set_uint32(d, "iobase", k->ide.get_iobase(sio, 0));
|
||||
@ -164,7 +164,7 @@ static void isa_superio_realize(DeviceState *dev, Error **errp)
|
||||
if (k->ide.get_irq) {
|
||||
qdev_prop_set_uint32(d, "irq", k->ide.get_irq(sio, 0));
|
||||
}
|
||||
qdev_init_nofail(d);
|
||||
isa_realize_and_unref(isa, bus, &error_fatal);
|
||||
object_property_add_child(OBJECT(sio), "isa-ide", OBJECT(isa));
|
||||
sio->ide = isa;
|
||||
trace_superio_create_ide(0,
|
||||
|
@ -244,6 +244,7 @@ static void ibm_40p_init(MachineState *machine)
|
||||
SysBusDevice *pcihost, *s;
|
||||
Nvram *m48t59 = NULL;
|
||||
PCIBus *pci_bus;
|
||||
ISADevice *isa_dev;
|
||||
ISABus *isa_bus;
|
||||
void *fw_cfg;
|
||||
int i;
|
||||
@ -292,14 +293,16 @@ static void ibm_40p_init(MachineState *machine)
|
||||
isa_bus = ISA_BUS(qdev_get_child_bus(i82378_dev, "isa.0"));
|
||||
|
||||
/* Memory controller */
|
||||
dev = DEVICE(isa_create(isa_bus, "rs6000-mc"));
|
||||
isa_dev = isa_new("rs6000-mc");
|
||||
dev = DEVICE(isa_dev);
|
||||
qdev_prop_set_uint32(dev, "ram-size", machine->ram_size);
|
||||
qdev_init_nofail(dev);
|
||||
isa_realize_and_unref(isa_dev, isa_bus, &error_fatal);
|
||||
|
||||
/* RTC */
|
||||
dev = DEVICE(isa_create(isa_bus, TYPE_MC146818_RTC));
|
||||
isa_dev = isa_new(TYPE_MC146818_RTC);
|
||||
dev = DEVICE(isa_dev);
|
||||
qdev_prop_set_int32(dev, "base_year", 1900);
|
||||
qdev_init_nofail(dev);
|
||||
isa_realize_and_unref(isa_dev, isa_bus, &error_fatal);
|
||||
|
||||
/* initialize CMOS checksums */
|
||||
cmos_checksum = 0x6aa9;
|
||||
@ -310,19 +313,22 @@ static void ibm_40p_init(MachineState *machine)
|
||||
if (defaults_enabled()) {
|
||||
m48t59 = NVRAM(isa_create_simple(isa_bus, "isa-m48t59"));
|
||||
|
||||
dev = DEVICE(isa_create(isa_bus, "cs4231a"));
|
||||
isa_dev = isa_new("cs4231a");
|
||||
dev = DEVICE(isa_dev);
|
||||
qdev_prop_set_uint32(dev, "iobase", 0x830);
|
||||
qdev_prop_set_uint32(dev, "irq", 10);
|
||||
qdev_init_nofail(dev);
|
||||
isa_realize_and_unref(isa_dev, isa_bus, &error_fatal);
|
||||
|
||||
dev = DEVICE(isa_create(isa_bus, "pc87312"));
|
||||
isa_dev = isa_new("pc87312");
|
||||
dev = DEVICE(isa_dev);
|
||||
qdev_prop_set_uint32(dev, "config", 12);
|
||||
qdev_init_nofail(dev);
|
||||
isa_realize_and_unref(isa_dev, isa_bus, &error_fatal);
|
||||
|
||||
dev = DEVICE(isa_create(isa_bus, "prep-systemio"));
|
||||
isa_dev = isa_new("prep-systemio");
|
||||
dev = DEVICE(isa_dev);
|
||||
qdev_prop_set_uint32(dev, "ibm-planar-id", 0xfc);
|
||||
qdev_prop_set_uint32(dev, "equipment", 0xc0);
|
||||
qdev_init_nofail(dev);
|
||||
isa_realize_and_unref(isa_dev, isa_bus, &error_fatal);
|
||||
|
||||
dev = DEVICE(pci_create_simple(pci_bus, PCI_DEVFN(1, 0),
|
||||
"lsi53c810"));
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "hw/qdev-properties.h"
|
||||
#include "hw/rtc/m48t59.h"
|
||||
#include "m48t59-internal.h"
|
||||
#include "qapi/error.h"
|
||||
#include "qemu/module.h"
|
||||
|
||||
#define TYPE_M48TXX_ISA "isa-m48txx"
|
||||
@ -61,6 +62,7 @@ static M48txxInfo m48txx_isa_info[] = {
|
||||
Nvram *m48t59_init_isa(ISABus *bus, uint32_t io_base, uint16_t size,
|
||||
int base_year, int model)
|
||||
{
|
||||
ISADevice *isa_dev;
|
||||
DeviceState *dev;
|
||||
int i;
|
||||
|
||||
@ -70,10 +72,11 @@ Nvram *m48t59_init_isa(ISABus *bus, uint32_t io_base, uint16_t size,
|
||||
continue;
|
||||
}
|
||||
|
||||
dev = DEVICE(isa_create(bus, m48txx_isa_info[i].bus_name));
|
||||
isa_dev = isa_new(m48txx_isa_info[i].bus_name);
|
||||
dev = DEVICE(isa_dev);
|
||||
qdev_prop_set_uint32(dev, "iobase", io_base);
|
||||
qdev_prop_set_int32(dev, "base-year", base_year);
|
||||
qdev_init_nofail(dev);
|
||||
isa_realize_and_unref(isa_dev, bus, &error_fatal);
|
||||
return NVRAM(dev);
|
||||
}
|
||||
|
||||
|
@ -974,10 +974,10 @@ ISADevice *mc146818_rtc_init(ISABus *bus, int base_year, qemu_irq intercept_irq)
|
||||
DeviceState *dev;
|
||||
ISADevice *isadev;
|
||||
|
||||
isadev = isa_create(bus, TYPE_MC146818_RTC);
|
||||
isadev = isa_new(TYPE_MC146818_RTC);
|
||||
dev = DEVICE(isadev);
|
||||
qdev_prop_set_int32(dev, "base_year", base_year);
|
||||
qdev_init_nofail(dev);
|
||||
isa_realize_and_unref(isadev, bus, &error_fatal);
|
||||
if (intercept_irq) {
|
||||
qdev_connect_gpio_out(dev, 0, intercept_irq);
|
||||
} else {
|
||||
|
@ -300,6 +300,7 @@ static void ebus_isa_irq_handler(void *opaque, int n, int level)
|
||||
static void ebus_realize(PCIDevice *pci_dev, Error **errp)
|
||||
{
|
||||
EbusState *s = EBUS(pci_dev);
|
||||
ISADevice *isa_dev;
|
||||
SysBusDevice *sbd;
|
||||
DeviceState *dev;
|
||||
qemu_irq *isa_irq;
|
||||
@ -338,7 +339,8 @@ static void ebus_realize(PCIDevice *pci_dev, Error **errp)
|
||||
for (i = 0; i < MAX_FD; i++) {
|
||||
fd[i] = drive_get(IF_FLOPPY, 0, i);
|
||||
}
|
||||
dev = DEVICE(isa_create(s->isa_bus, TYPE_ISA_FDC));
|
||||
isa_dev = isa_new(TYPE_ISA_FDC);
|
||||
dev = DEVICE(isa_dev);
|
||||
if (fd[0]) {
|
||||
qdev_prop_set_drive(dev, "driveA", blk_by_legacy_dinfo(fd[0]),
|
||||
&error_abort);
|
||||
@ -348,7 +350,7 @@ static void ebus_realize(PCIDevice *pci_dev, Error **errp)
|
||||
&error_abort);
|
||||
}
|
||||
qdev_prop_set_uint32(dev, "dma", -1);
|
||||
qdev_init_nofail(dev);
|
||||
isa_realize_and_unref(isa_dev, s->isa_bus, &error_fatal);
|
||||
|
||||
/* Power */
|
||||
dev = qdev_new(TYPE_SUN4U_POWER);
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
#include "hw/isa/isa.h"
|
||||
#include "hw/qdev-properties.h"
|
||||
#include "qapi/error.h"
|
||||
|
||||
#define TYPE_PC_SPEAKER "isa-pcspk"
|
||||
|
||||
@ -35,11 +36,11 @@ static inline ISADevice *pcspk_init(ISABus *bus, ISADevice *pit)
|
||||
DeviceState *dev;
|
||||
ISADevice *isadev;
|
||||
|
||||
isadev = isa_create(bus, TYPE_PC_SPEAKER);
|
||||
isadev = isa_new(TYPE_PC_SPEAKER);
|
||||
dev = DEVICE(isadev);
|
||||
qdev_prop_set_uint32(dev, "iobase", 0x61);
|
||||
object_property_set_link(OBJECT(dev), OBJECT(pit), "pit", NULL);
|
||||
qdev_init_nofail(dev);
|
||||
isa_realize_and_unref(isadev, bus, &error_fatal);
|
||||
|
||||
return isadev;
|
||||
}
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
#include "hw/qdev-properties.h"
|
||||
#include "hw/isa/isa.h"
|
||||
#include "qapi/error.h"
|
||||
|
||||
#define PIT_FREQ 1193182
|
||||
|
||||
@ -54,10 +55,10 @@ static inline ISADevice *i8254_pit_init(ISABus *bus, int base, int isa_irq,
|
||||
DeviceState *dev;
|
||||
ISADevice *d;
|
||||
|
||||
d = isa_create(bus, TYPE_I8254);
|
||||
d = isa_new(TYPE_I8254);
|
||||
dev = DEVICE(d);
|
||||
qdev_prop_set_uint32(dev, "iobase", base);
|
||||
qdev_init_nofail(dev);
|
||||
isa_realize_and_unref(d, bus, &error_fatal);
|
||||
qdev_connect_gpio_out(dev, 0,
|
||||
isa_irq >= 0 ? isa_get_irq(d, isa_irq) : alt_irq);
|
||||
|
||||
@ -69,10 +70,10 @@ static inline ISADevice *kvm_pit_init(ISABus *bus, int base)
|
||||
DeviceState *dev;
|
||||
ISADevice *d;
|
||||
|
||||
d = isa_create(bus, TYPE_KVM_I8254);
|
||||
d = isa_new(TYPE_KVM_I8254);
|
||||
dev = DEVICE(d);
|
||||
qdev_prop_set_uint32(dev, "iobase", base);
|
||||
qdev_init_nofail(dev);
|
||||
isa_realize_and_unref(d, bus, &error_fatal);
|
||||
|
||||
return d;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user