From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:37925) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SgcUv-0001ef-Bh for qemu-devel@nongnu.org; Mon, 18 Jun 2012 10:00:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SgcUb-0003YO-VZ for qemu-devel@nongnu.org; Mon, 18 Jun 2012 10:00:04 -0400 Received: from cantor2.suse.de ([195.135.220.15]:53268 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SgcUb-0003Y4-MT for qemu-devel@nongnu.org; Mon, 18 Jun 2012 09:59:45 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Mon, 18 Jun 2012 15:59:08 +0200 Message-Id: <1340027954-19045-17-git-send-email-afaerber@suse.de> In-Reply-To: <1340027954-19045-1-git-send-email-afaerber@suse.de> References: <1340027954-19045-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH 16/22] qdev: Move SysBus initialization to sysbus.c List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Anthony Liguori From: Paolo Bonzini TYPE_SYSTEM_BUS will be local to hw/sysbus.c, so move existing references to main_system_bus and system_bus_info there. Signed-off-by: Paolo Bonzini Signed-off-by: Andreas F=C3=A4rber --- hw/qdev.c | 26 ++------------------------ hw/sysbus.c | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/hw/qdev.c b/hw/qdev.c index 7b2802d..7816a37 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -34,10 +34,6 @@ int qdev_hotplug =3D 0; static bool qdev_hot_added =3D false; static bool qdev_hot_removed =3D false; =20 -/* This is a nasty hack to allow passing a NULL bus to qdev_create. */ -static BusState *main_system_bus; -static void main_system_bus_create(void); - /* Register a new device type. */ const VMStateDescription *qdev_get_vmsd(DeviceState *dev) { @@ -188,14 +184,6 @@ static int qdev_reset_one(DeviceState *dev, void *op= aque) return 0; } =20 -BusState *sysbus_get_default(void) -{ - if (!main_system_bus) { - main_system_bus_create(); - } - return main_system_bus; -} - static int qbus_reset_one(BusState *bus, void *opaque) { if (bus->info->reset) { @@ -415,7 +403,7 @@ void qbus_create_inplace(BusState *bus, BusInfo *info= , if (parent) { QLIST_INSERT_HEAD(&parent->child_bus, bus, sibling); parent->num_child_bus++; - } else if (bus !=3D main_system_bus) { + } else if (bus !=3D sysbus_get_default()) { /* TODO: once all bus devices are qdevified, only reset handler for main_system_bus should be registered h= ere. */ qemu_register_reset(qbus_reset_all_fn, bus); @@ -432,16 +420,6 @@ BusState *qbus_create(BusInfo *info, DeviceState *pa= rent, const char *name) return bus; } =20 -static void main_system_bus_create(void) -{ - /* assign main_system_bus before qbus_create_inplace() - * in order to make "if (bus !=3D main_system_bus)" work */ - main_system_bus =3D g_malloc0(system_bus_info.size); - main_system_bus->qdev_allocated =3D 1; - qbus_create_inplace(main_system_bus, &system_bus_info, NULL, - "main-system-bus"); -} - void qbus_free(BusState *bus) { DeviceState *dev; @@ -453,7 +431,7 @@ void qbus_free(BusState *bus) QLIST_REMOVE(bus, sibling); bus->parent->num_child_bus--; } else { - assert(bus !=3D main_system_bus); /* main_system_bus is never fr= eed */ + assert(bus !=3D sysbus_get_default()); /* main_system_bus is nev= er freed */ qemu_unregister_reset(qbus_reset_all_fn, bus); } g_free((void*)bus->name); diff --git a/hw/sysbus.c b/hw/sysbus.c index db4efcc..fe5c421 100644 --- a/hw/sysbus.c +++ b/hw/sysbus.c @@ -256,6 +256,27 @@ static TypeInfo sysbus_device_type_info =3D { .class_init =3D sysbus_device_class_init, }; =20 +/* This is a nasty hack to allow passing a NULL bus to qdev_create. */ +static BusState *main_system_bus; + +static void main_system_bus_create(void) +{ + /* assign main_system_bus before qbus_create_inplace() + * in order to make "if (bus !=3D sysbus_get_default())" work */ + main_system_bus =3D g_malloc0(system_bus_info.size); + main_system_bus->qdev_allocated =3D 1; + qbus_create_inplace(main_system_bus, &system_bus_info, NULL, + "main-system-bus"); +} + +BusState *sysbus_get_default(void) +{ + if (!main_system_bus) { + main_system_bus_create(); + } + return main_system_bus; +} + static void sysbus_register_types(void) { type_register_static(&sysbus_device_type_info); --=20 1.7.7