summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2009-07-15 13:43:32 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2009-07-16 17:28:52 -0500
commit81ebb98b24eb5ea0f9d5a2717d71bcd01d652972 (patch)
treeafbdd3acd0be6c9438e1a4ca293e65c64e41dabe
parent15239b2e52633128c0b7f806175243c0969196e6 (diff)
downloadqemu-81ebb98b24eb5ea0f9d5a2717d71bcd01d652972.tar.gz
qdev: factor out driver search to qdev_find_info()
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
-rw-r--r--hw/qdev.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/hw/qdev.c b/hw/qdev.c
index 64461e7eb2..a53125dd88 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -46,6 +46,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. */
@@ -61,13 +75,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);
}