From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:51915) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RhsdB-0002SF-Gb for qemu-devel@nongnu.org; Mon, 02 Jan 2012 19:53:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rhsd5-0008Pk-T8 for qemu-devel@nongnu.org; Mon, 02 Jan 2012 19:53:33 -0500 Received: from e7.ny.us.ibm.com ([32.97.182.137]:42570) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rhsd5-0008Pe-Lj for qemu-devel@nongnu.org; Mon, 02 Jan 2012 19:53:27 -0500 Received: from /spool/local by e7.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 2 Jan 2012 19:53:26 -0500 Received: from d01av02.pok.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by d01relay03.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q030qcYj307816 for ; Mon, 2 Jan 2012 19:52:38 -0500 Received: from d01av02.pok.ibm.com (loopback [127.0.0.1]) by d01av02.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q030qbD6001630 for ; Mon, 2 Jan 2012 22:52:37 -0200 From: Anthony Liguori Date: Mon, 2 Jan 2012 18:52:01 -0600 Message-Id: <1325551939-24749-13-git-send-email-aliguori@us.ibm.com> In-Reply-To: <1325551939-24749-1-git-send-email-aliguori@us.ibm.com> References: <1325551939-24749-1-git-send-email-aliguori@us.ibm.com> Subject: [Qemu-devel] [PATCH 12/30] qdev: add a interface to register subclasses List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Anthony Liguori , Markus Armbruster , =?UTF-8?q?Andreas=20F=C3=A4rber?= In order to introduce inheritance while still using the qdev registration interfaces, we need to be able to use a parent other than TYPE_DEVICE. Add a new interface that allows this. Signed-off-by: Anthony Liguori --- hw/qdev.c | 9 +++++++-- hw/qdev.h | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/hw/qdev.c b/hw/qdev.c index c26b1e7..7c4d3ca 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -61,7 +61,7 @@ DeviceInfo *qdev_get_info(DeviceState *dev) return DEVICE_GET_CLASS(dev)->info; } -void qdev_register(DeviceInfo *info) +void qdev_register_subclass(DeviceInfo *info, const char *parent) { TypeInfo type_info = {}; @@ -69,7 +69,7 @@ void qdev_register(DeviceInfo *info) assert(!info->next); type_info.name = info->name; - type_info.parent = TYPE_DEVICE; + type_info.parent = parent; type_info.instance_size = info->size; type_info.class_init = qdev_subclass_init; type_info.class_data = info; @@ -80,6 +80,11 @@ void qdev_register(DeviceInfo *info) device_info_list = info; } +void qdev_register(DeviceInfo *info) +{ + qdev_register_subclass(info, TYPE_DEVICE); +} + static DeviceInfo *qdev_find_info(BusInfo *bus_info, const char *name) { DeviceInfo *info; diff --git a/hw/qdev.h b/hw/qdev.h index 822186e..742f421 100644 --- a/hw/qdev.h +++ b/hw/qdev.h @@ -240,6 +240,7 @@ struct DeviceInfo { extern DeviceInfo *device_info_list; void qdev_register(DeviceInfo *info); +void qdev_register_subclass(DeviceInfo *info, const char *parent); /* Register device properties. */ /* GPIO inputs also double as IRQ sinks. */ -- 1.7.4.1