[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 05/22] qdev: allow classes to overload qdev function
From: |
Anthony Liguori |
Subject: |
[Qemu-devel] [PATCH 05/22] qdev: allow classes to overload qdev functions |
Date: |
Wed, 1 Feb 2012 13:50:46 -0600 |
This allows us to drop per-Device registration functions by allowing the
class_init functions to overload qdev methods.
Signed-off-by: Anthony Liguori <address@hidden>
---
hw/qdev.c | 53 +++++++++++++++++++++++++++++++++--------------------
1 files changed, 33 insertions(+), 20 deletions(-)
diff --git a/hw/qdev.c b/hw/qdev.c
index b273cd2..c9f890c 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -50,21 +50,39 @@ static void qdev_subclass_init(ObjectClass *klass, void
*data)
DeviceClass *dc = DEVICE_CLASS(klass);
DeviceInfo *info = data;
- dc->fw_name = info->fw_name;
- dc->alias = info->alias;
- dc->desc = info->desc;
- dc->props = info->props;
- dc->no_user = info->no_user;
-
- dc->reset = info->reset;
-
- dc->vmsd = info->vmsd;
-
- dc->init = info->init;
- dc->unplug = info->unplug;
- dc->exit = info->exit;
- dc->bus_info = info->bus_info;
-
+ if (info->fw_name) {
+ dc->fw_name = info->fw_name;
+ }
+ if (info->alias) {
+ dc->alias = info->alias;
+ }
+ if (info->desc) {
+ dc->desc = info->desc;
+ }
+ if (info->props) {
+ dc->props = info->props;
+ }
+ if (info->no_user) {
+ dc->no_user = info->no_user;
+ }
+ if (info->reset) {
+ dc->reset = info->reset;
+ }
+ if (info->vmsd) {
+ dc->vmsd = info->vmsd;
+ }
+ if (info->init) {
+ dc->init = info->init;
+ }
+ if (info->unplug) {
+ dc->unplug = info->unplug;
+ }
+ if (info->exit) {
+ dc->exit = info->exit;
+ }
+ if (info->bus_info) {
+ dc->bus_info = info->bus_info;
+ }
if (info->class_init) {
info->class_init(klass, data);
}
@@ -131,8 +149,6 @@ static DeviceInfo *qdev_find_info(BusInfo *bus_info, const
char *name)
/* first check device names */
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;
@@ -140,8 +156,6 @@ static DeviceInfo *qdev_find_info(BusInfo *bus_info, const
char *name)
/* failing that check the aliases */
for (info = device_info_list; info != NULL; info = info->next) {
- if (bus_info && info->bus_info != bus_info)
- continue;
if (!info->alias)
continue;
if (strcmp(info->alias, name) != 0)
@@ -164,7 +178,6 @@ static DeviceState *qdev_create_from_info(BusState *bus,
DeviceInfo *info)
DeviceState *dev;
Property *prop;
- assert(bus->info == info->bus_info);
dev = DEVICE(object_new(info->name));
dev->parent_bus = bus;
qdev_prop_set_defaults(dev, qdev_get_props(dev));
--
1.7.4.1
- [Qemu-devel] [PATCH 00/22] qom: use Type system to register all devices (v2), Anthony Liguori, 2012/02/01
- [Qemu-devel] [PATCH 01/22] usb-hid: simplify class initialization a bit, Anthony Liguori, 2012/02/01
- [Qemu-devel] [PATCH 02/22] usb: separate out legacy usb registration from type registration, Anthony Liguori, 2012/02/01
- [Qemu-devel] [PATCH 03/22] qdev: make DeviceInfo private, Anthony Liguori, 2012/02/01
- [Qemu-devel] [PATCH 04/22] qdev: remove info from class, Anthony Liguori, 2012/02/01
- [Qemu-devel] [PATCH 06/22] qdev: refactor device creation to allow bus_info to be set only in class, Anthony Liguori, 2012/02/01
- [Qemu-devel] [PATCH 05/22] qdev: allow classes to overload qdev functions,
Anthony Liguori <=
- [Qemu-devel] [PATCH 08/22] qdev: kill off DeviceInfo list, Anthony Liguori, 2012/02/01
- [Qemu-devel] [PATCH 10/22] qdev: kill off DeviceInfo, Anthony Liguori, 2012/02/01
- [Qemu-devel] [PATCH 11/22] qdev: remove baked in notion of aliases (v2), Anthony Liguori, 2012/02/01
- [Qemu-devel] [PATCH 16/22] qdev: nuke qdev_init_chardev(), Anthony Liguori, 2012/02/01
- [Qemu-devel] [PATCH 15/22] qdev: split out UI portions into a new function, Anthony Liguori, 2012/02/01
- [Qemu-devel] [PATCH 12/22] qom: add new command to search for types, Anthony Liguori, 2012/02/01
- [Qemu-devel] [PATCH 17/22] qom: move properties from qdev to object, Anthony Liguori, 2012/02/01
- [Qemu-devel] [PATCH 20/22] info qdm: do not require a parent_bus to be set, Anthony Liguori, 2012/02/01
- [Qemu-devel] [PATCH 21/22] object: sure up reference counting, Anthony Liguori, 2012/02/01
- [Qemu-devel] [PATCH 09/22] qdev: register all types natively through QEMU Object Model, Anthony Liguori, 2012/02/01