diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2013-01-25 14:12:27 +0100 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2013-02-01 15:53:09 -0600 |
commit | 013e118247d0f1894f329ad31b8f8a9e279555f3 (patch) | |
tree | 02110582d1254e4c9ec09cee637de37652d8704c | |
parent | d5286af5ef27bfe25aa0472eb4d695964ae16b23 (diff) | |
download | qemu-013e118247d0f1894f329ad31b8f8a9e279555f3.zip qemu-013e118247d0f1894f329ad31b8f8a9e279555f3.tar.gz qemu-013e118247d0f1894f329ad31b8f8a9e279555f3.tar.bz2 |
qdev: remove duplication between qbus_create and qbus_create_inplace
Move the common part to qbus_realize.
Acked-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
-rw-r--r-- | hw/qdev.c | 18 |
1 files changed, 7 insertions, 11 deletions
@@ -390,14 +390,16 @@ DeviceState *qdev_find_recursive(BusState *bus, const char *id) return NULL; } -static void qbus_realize(BusState *bus) +static void qbus_realize(BusState *bus, DeviceState *parent, const char *name) { const char *typename = object_get_typename(OBJECT(bus)); char *buf; int i,len; - if (bus->name) { - /* use supplied name */ + bus->parent = parent; + + if (name) { + bus->name = g_strdup(name); } else if (bus->parent && bus->parent->id) { /* parent device has id -> use it for bus name */ len = strlen(bus->parent->id) + 16; @@ -430,10 +432,7 @@ void qbus_create_inplace(BusState *bus, const char *typename, DeviceState *parent, const char *name) { object_initialize(bus, typename); - - bus->parent = parent; - bus->name = name ? g_strdup(name) : NULL; - qbus_realize(bus); + qbus_realize(bus, parent, name); } BusState *qbus_create(const char *typename, DeviceState *parent, const char *name) @@ -441,10 +440,7 @@ BusState *qbus_create(const char *typename, DeviceState *parent, const char *nam BusState *bus; bus = BUS(object_new(typename)); - - bus->parent = parent; - bus->name = name ? g_strdup(name) : NULL; - qbus_realize(bus); + qbus_realize(bus, parent, name); return bus; } |