diff options
author | Markus Armbruster <armbru@redhat.com> | 2020-06-10 07:32:08 +0200 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2020-06-15 22:05:28 +0200 |
commit | 96927c744f9cd5205f95ef897c35695038dc2896 (patch) | |
tree | 5da3a4cb78c4ea9f2b9ae4c240d3f22d5cd24dae /include | |
parent | 0fe9d9011971820b2dab27aa49cfb957b91cc3e2 (diff) |
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>
Diffstat (limited to 'include')
-rw-r--r-- | include/hw/audio/pcspk.h | 5 | ||||
-rw-r--r-- | include/hw/timer/i8254.h | 9 |
2 files changed, 8 insertions, 6 deletions
diff --git a/include/hw/audio/pcspk.h b/include/hw/audio/pcspk.h index 632cce9f68..7e7f5f49dc 100644 --- a/include/hw/audio/pcspk.h +++ b/include/hw/audio/pcspk.h @@ -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; } diff --git a/include/hw/timer/i8254.h b/include/hw/timer/i8254.h index 45cb42571f..e75b4a5a08 100644 --- a/include/hw/timer/i8254.h +++ b/include/hw/timer/i8254.h @@ -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; } |