aboutsummaryrefslogtreecommitdiff
path: root/hw/misc/macio
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2020-06-10 07:32:37 +0200
committerMarkus Armbruster <armbru@redhat.com>2020-06-15 22:06:04 +0200
commitdb873cc5d1a4aaa67eea87768d504b2f89d88738 (patch)
tree5979d3c93f4c66784c1447ae27b8153ae4e42fa3 /hw/misc/macio
parent0074fce61fecf40326845fa859119bbdd96df620 (diff)
sysbus: Convert qdev_set_parent_bus() use with Coccinelle, part 2
This is the same transformation as in the previous commit, except sysbus_init_child_obj() and realize are too separated for the commit's Coccinelle script to handle, typically because sysbus_init_child_obj() is in a device's instance_init() method, and the matching realize is in its realize() method. Perhaps a Coccinelle wizard could make it transform that pattern, but I'm just a bungler, and the best I can do is transforming the two separate parts separately: @@ expression errp; expression child; symbol true; @@ - object_property_set_bool(OBJECT(child), true, "realized", errp); + sysbus_realize(SYS_BUS_DEVICE(child), errp); // only correct with a matching sysbus_init_child_obj() transformation! @@ expression errp; expression child; symbol true; @@ - object_property_set_bool(child, true, "realized", errp); + sysbus_realize(SYS_BUS_DEVICE(child), errp); // only correct with a matching sysbus_init_child_obj() transformation! @@ expression child; @@ - qdev_init_nofail(DEVICE(child)); + sysbus_realize(SYS_BUS_DEVICE(child), &error_fatal); // only correct with a matching sysbus_init_child_obj() transformation! @@ expression child; expression dev; @@ dev = DEVICE(child); ... - qdev_init_nofail(dev); + sysbus_realize(SYS_BUS_DEVICE(dev), &error_fatal); // only correct with a matching sysbus_init_child_obj() transformation! @@ expression child; identifier dev; @@ DeviceState *dev = DEVICE(child); ... - qdev_init_nofail(dev); + sysbus_realize(SYS_BUS_DEVICE(dev), &error_fatal); // only correct with a matching sysbus_init_child_obj() transformation! @@ expression parent, name, size, type; expression child; symbol true; @@ - sysbus_init_child_obj(parent, name, child, size, type); + sysbus_init_child_XXX(parent, name, child, size, type); @@ expression parent, propname, type; expression child; @@ - sysbus_init_child_XXX(parent, propname, child, sizeof(*child), type) + object_initialize_child(parent, propname, child, type) @@ expression parent, propname, type; expression child; @@ - sysbus_init_child_XXX(parent, propname, &child, sizeof(child), type) + object_initialize_child(parent, propname, &child, type) This script is *unsound*: we need to manually verify init and realize conversions are properly paired. This commit has only the pairs where object_initialize_child()'s @child and sysbus_realize()'s @dev argument text match exactly within the same source file. Note that Coccinelle chokes on ARMSSE typedef vs. macro in hw/arm/armsse.c. Worked around by temporarily renaming the macro for the spatch run. Signed-off-by: Markus Armbruster <armbru@redhat.com> Acked-by: Alistair Francis <alistair.francis@wdc.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Message-Id: <20200610053247.1583243-49-armbru@redhat.com>
Diffstat (limited to 'hw/misc/macio')
-rw-r--r--hw/misc/macio/cuda.c8
-rw-r--r--hw/misc/macio/pmu.c8
2 files changed, 8 insertions, 8 deletions
diff --git a/hw/misc/macio/cuda.c b/hw/misc/macio/cuda.c
index 3cb10c743c..47aa3b0552 100644
--- a/hw/misc/macio/cuda.c
+++ b/hw/misc/macio/cuda.c
@@ -31,6 +31,7 @@
#include "hw/input/adb.h"
#include "hw/misc/mos6522.h"
#include "hw/misc/macio/cuda.h"
+#include "qapi/error.h"
#include "qemu/timer.h"
#include "sysemu/runstate.h"
#include "qapi/error.h"
@@ -527,8 +528,7 @@ static void cuda_realize(DeviceState *dev, Error **errp)
SysBusDevice *sbd;
struct tm tm;
- object_property_set_bool(OBJECT(&s->mos6522_cuda), true, "realized",
- &err);
+ sysbus_realize(SYS_BUS_DEVICE(&s->mos6522_cuda), &err);
if (err) {
error_propagate(errp, err);
return;
@@ -554,8 +554,8 @@ static void cuda_init(Object *obj)
CUDAState *s = CUDA(obj);
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
- sysbus_init_child_obj(obj, "mos6522-cuda", &s->mos6522_cuda,
- sizeof(s->mos6522_cuda), TYPE_MOS6522_CUDA);
+ object_initialize_child(obj, "mos6522-cuda", &s->mos6522_cuda,
+ TYPE_MOS6522_CUDA);
memory_region_init_io(&s->mem, obj, &mos6522_cuda_ops, s, "cuda", 0x2000);
sysbus_init_mmio(sbd, &s->mem);
diff --git a/hw/misc/macio/pmu.c b/hw/misc/macio/pmu.c
index 0895b78b59..41b626c46c 100644
--- a/hw/misc/macio/pmu.c
+++ b/hw/misc/macio/pmu.c
@@ -38,6 +38,7 @@
#include "hw/misc/mos6522.h"
#include "hw/misc/macio/gpio.h"
#include "hw/misc/macio/pmu.h"
+#include "qapi/error.h"
#include "qemu/timer.h"
#include "sysemu/runstate.h"
#include "qapi/error.h"
@@ -744,8 +745,7 @@ static void pmu_realize(DeviceState *dev, Error **errp)
SysBusDevice *sbd;
struct tm tm;
- object_property_set_bool(OBJECT(&s->mos6522_pmu), true, "realized",
- &err);
+ sysbus_realize(SYS_BUS_DEVICE(&s->mos6522_pmu), &err);
if (err) {
error_propagate(errp, err);
return;
@@ -780,8 +780,8 @@ static void pmu_init(Object *obj)
qdev_prop_allow_set_link_before_realize,
0);
- sysbus_init_child_obj(obj, "mos6522-pmu", &s->mos6522_pmu,
- sizeof(s->mos6522_pmu), TYPE_MOS6522_PMU);
+ object_initialize_child(obj, "mos6522-pmu", &s->mos6522_pmu,
+ TYPE_MOS6522_PMU);
memory_region_init_io(&s->mem, obj, &mos6522_pmu_ops, s, "via-pmu",
0x2000);