diff options
author | Thomas Huth <thuth@redhat.com> | 2018-07-16 14:59:19 +0200 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2018-07-17 13:12:49 +0100 |
commit | 046f370fb44172a34e54e341e7aeca4405af67a1 (patch) | |
tree | fe366e5afbc789b872ff44c8ef94bf783b7f0082 /hw/core/sysbus.c | |
parent | 0210b39d0e84d5a63a3e468f177c07a3a98d88a8 (diff) | |
download | qemu-046f370fb44172a34e54e341e7aeca4405af67a1.zip qemu-046f370fb44172a34e54e341e7aeca4405af67a1.tar.gz qemu-046f370fb44172a34e54e341e7aeca4405af67a1.tar.bz2 |
hw/core/sysbus: Add a function for creating and attaching an object
A lot of functions are initializing an object and attach it immediately
afterwards to the system bus. Provide a common function for this, which
also uses object_initialize_child() to make sure that the reference
counter is correctly initialized to 1 afterwards.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Message-id: 1531745974-17187-3-git-send-email-thuth@redhat.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'hw/core/sysbus.c')
-rw-r--r-- | hw/core/sysbus.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c index ecfb0cf..3c8e53b 100644 --- a/hw/core/sysbus.c +++ b/hw/core/sysbus.c @@ -376,6 +376,14 @@ BusState *sysbus_get_default(void) return main_system_bus; } +void sysbus_init_child_obj(Object *parent, const char *childname, void *child, + size_t childsize, const char *childtype) +{ + object_initialize_child(parent, childname, child, childsize, childtype, + &error_abort, NULL); + qdev_set_parent_bus(DEVICE(child), sysbus_get_default()); +} + static void sysbus_register_types(void) { type_register_static(&system_bus_info); |