From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MR2to-0002lM-RG for qemu-devel@nongnu.org; Wed, 15 Jul 2009 07:43:49 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MR2tj-0002i0-Jd for qemu-devel@nongnu.org; Wed, 15 Jul 2009 07:43:48 -0400 Received: from [199.232.76.173] (port=56673 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MR2tj-0002hq-Aj for qemu-devel@nongnu.org; Wed, 15 Jul 2009 07:43:43 -0400 Received: from mx2.redhat.com ([66.187.237.31]:36366) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MR2ti-00039I-NN for qemu-devel@nongnu.org; Wed, 15 Jul 2009 07:43:43 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n6FBhgxO013562 for ; Wed, 15 Jul 2009 07:43:42 -0400 From: Gerd Hoffmann Date: Wed, 15 Jul 2009 13:43:32 +0200 Message-Id: <1247658216-511-3-git-send-email-kraxel@redhat.com> In-Reply-To: <1247658216-511-1-git-send-email-kraxel@redhat.com> References: <1247658216-511-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 2/6] qdev: factor out driver search to qdev_find_info() List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann Signed-off-by: Gerd Hoffmann --- hw/qdev.c | 22 +++++++++++++++------- 1 files changed, 15 insertions(+), 7 deletions(-) diff --git a/hw/qdev.c b/hw/qdev.c index 9912bd9..644a5be 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -47,6 +47,20 @@ void qdev_register(DeviceInfo *info) device_info_list = info; } +static DeviceInfo *qdev_find_info(BusInfo *bus_info, const char *name) +{ + DeviceInfo *info; + + for (info = device_info_list; info != NULL; info = info->next) { + if (bus_info && info->bus_info != bus_info) + continue; + if (strcmp(info->name, name) != 0) + continue; + return info; + } + return NULL; +} + /* Create a new device. This only initializes the device state structure and allows properties to be set. qdev_init should be called to initialize the actual device emulation. */ @@ -62,13 +76,7 @@ DeviceState *qdev_create(BusState *bus, const char *name) bus = main_system_bus; } - for (info = device_info_list; info != NULL; info = info->next) { - if (info->bus_info != bus->info) - continue; - if (strcmp(info->name, name) != 0) - continue; - break; - } + info = qdev_find_info(bus->info, name); if (!info) { hw_error("Unknown device '%s' for bus '%s'\n", name, bus->info->name); } -- 1.6.2.5