qdev: Convert bus-less devices to qdev_realize() with Coccinelle

All remaining conversions to qdev_realize() are for bus-less devices.
Coccinelle script:

    // only correct for bus-less @dev!

    @@
    expression errp;
    expression dev;
    @@
    -    qdev_init_nofail(dev);
    +    qdev_realize(dev, NULL, &error_fatal);

    @ depends on !(file in "hw/core/qdev.c") && !(file in "hw/core/bus.c")@
    expression errp;
    expression dev;
    symbol true;
    @@
    -    object_property_set_bool(OBJECT(dev), true, "realized", errp);
    +    qdev_realize(DEVICE(dev), NULL, errp);

    @ depends on !(file in "hw/core/qdev.c") && !(file in "hw/core/bus.c")@
    expression errp;
    expression dev;
    symbol true;
    @@
    -    object_property_set_bool(dev, true, "realized", errp);
    +    qdev_realize(DEVICE(dev), NULL, errp);

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-57-armbru@redhat.com>
This commit is contained in:
Markus Armbruster 2020-06-10 07:32:45 +02:00
parent 464a22c757
commit ce189ab230
80 changed files with 124 additions and 152 deletions

View file

@ -26,6 +26,7 @@
#include "hw/qdev-properties.h"
#include "qom/object.h"
#include "qapi/error.h"
#include "qapi/visitor.h"
@ -76,7 +77,7 @@ static void test_static_prop_subprocess(void)
MyType *mt;
mt = STATIC_TYPE(object_new(TYPE_STATIC_PROPS));
qdev_init_nofail(DEVICE(mt));
qdev_realize(DEVICE(mt), NULL, &error_fatal);
g_assert_cmpuint(mt->prop1, ==, PROP_DEFAULT);
}
@ -111,7 +112,7 @@ static void test_static_globalprop_subprocess(void)
register_global_properties(props);
mt = STATIC_TYPE(object_new(TYPE_STATIC_PROPS));
qdev_init_nofail(DEVICE(mt));
qdev_realize(DEVICE(mt), NULL, &error_fatal);
g_assert_cmpuint(mt->prop1, ==, 200);
g_assert_cmpuint(mt->prop2, ==, PROP_DEFAULT);
@ -229,7 +230,7 @@ static void test_dynamic_globalprop_subprocess(void)
register_global_properties(props);
mt = DYNAMIC_TYPE(object_new(TYPE_DYNAMIC_PROPS));
qdev_init_nofail(DEVICE(mt));
qdev_realize(DEVICE(mt), NULL, &error_fatal);
g_assert_cmpuint(mt->prop1, ==, 101);
g_assert_cmpuint(mt->prop2, ==, 102);
@ -272,7 +273,7 @@ static void test_subclass_global_props(void)
register_global_properties(props);
mt = STATIC_TYPE(object_new(TYPE_SUBCLASS));
qdev_init_nofail(DEVICE(mt));
qdev_realize(DEVICE(mt), NULL, &error_fatal);
g_assert_cmpuint(mt->prop1, ==, 102);
g_assert_cmpuint(mt->prop2, ==, 104);