diff options
author | Markus Armbruster | 2020-06-10 07:32:08 +0200 |
---|---|---|
committer | Markus Armbruster | 2020-06-15 22:05:28 +0200 |
commit | 96927c744f9cd5205f95ef897c35695038dc2896 (patch) | |
tree | 5da3a4cb78c4ea9f2b9ae4c240d3f22d5cd24dae /hw/char | |
parent | isa: New isa_new(), isa_realize_and_unref() etc. (diff) | |
download | qemu-96927c744f9cd5205f95ef897c35695038dc2896.tar.gz qemu-96927c744f9cd5205f95ef897c35695038dc2896.tar.xz qemu-96927c744f9cd5205f95ef897c35695038dc2896.zip |
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 'hw/char')
-rw-r--r-- | hw/char/parallel-isa.c | 5 | ||||
-rw-r--r-- | hw/char/serial-isa.c | 4 |
2 files changed, 5 insertions, 4 deletions
diff --git a/hw/char/parallel-isa.c b/hw/char/parallel-isa.c index bcc577f61c..1ccbb96e70 100644 --- a/hw/char/parallel-isa.c +++ b/hw/char/parallel-isa.c @@ -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) diff --git a/hw/char/serial-isa.c b/hw/char/serial-isa.c index 165e320e65..d69aab5714 100644 --- a/hw/char/serial-isa.c +++ b/hw/char/serial-isa.c @@ -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) |