From patchwork Tue Jan 24 19:33:01 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony Liguori X-Patchwork-Id: 137618 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id BB4E31007D3 for ; Wed, 25 Jan 2012 06:34:55 +1100 (EST) Received: from localhost ([::1]:47391 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rpm8l-0002aR-Ek for incoming@patchwork.ozlabs.org; Tue, 24 Jan 2012 14:34:47 -0500 Received: from eggs.gnu.org ([140.186.70.92]:50032) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rpm8c-0002aK-R8 for qemu-devel@nongnu.org; Tue, 24 Jan 2012 14:34:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rpm8Y-0004cI-Lf for qemu-devel@nongnu.org; Tue, 24 Jan 2012 14:34:38 -0500 Received: from e38.co.us.ibm.com ([32.97.110.159]:45856) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rpm8Y-0004c7-Bq for qemu-devel@nongnu.org; Tue, 24 Jan 2012 14:34:34 -0500 Received: from /spool/local by e38.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 24 Jan 2012 12:34:32 -0700 Received: from d03dlp02.boulder.ibm.com (9.17.202.178) by e38.co.us.ibm.com (192.168.1.138) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 24 Jan 2012 12:33:42 -0700 Received: from d03relay02.boulder.ibm.com (d03relay02.boulder.ibm.com [9.17.195.227]) by d03dlp02.boulder.ibm.com (Postfix) with ESMTP id 4790B3E40051 for ; Tue, 24 Jan 2012 12:33:41 -0700 (MST) Received: from d03av01.boulder.ibm.com (d03av01.boulder.ibm.com [9.17.195.167]) by d03relay02.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q0OJXYaQ120384 for ; Tue, 24 Jan 2012 12:33:35 -0700 Received: from d03av01.boulder.ibm.com (loopback [127.0.0.1]) by d03av01.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q0OJXYIE007975 for ; Tue, 24 Jan 2012 12:33:34 -0700 Received: from titi.austin.rr.com (sig-9-65-115-125.mts.ibm.com [9.65.115.125]) by d03av01.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q0OJXNdR006821; Tue, 24 Jan 2012 12:33:34 -0700 From: Anthony Liguori To: qemu-devel@nongnu.org Date: Tue, 24 Jan 2012 13:33:01 -0600 Message-Id: <1327433600-7403-10-git-send-email-aliguori@us.ibm.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1327433600-7403-1-git-send-email-aliguori@us.ibm.com> References: <1327433600-7403-1-git-send-email-aliguori@us.ibm.com> X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12012419-5518-0000-0000-000001C49618 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 32.97.110.159 Cc: Anthony Liguori Subject: [Qemu-devel] [PATCH 09/28] qdev: add a interface to register subclasses X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 a80ca7c..c4b5284 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 f3c9219..48f80a5 100644 --- a/hw/qdev.h +++ b/hw/qdev.h @@ -241,6 +241,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. */