Received: from eggs.gnu.org ([208.118.235.92]:49486) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TtfQe-00070Q-56 for qemu-devel@nongnu.org; Fri, 11 Jan 2013 09:17:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TtfQa-0005Ad-2q for qemu-devel@nongnu.org; Fri, 11 Jan 2013 09:17:51 -0500 Received: from e35.co.us.ibm.com ([32.97.110.153]:37035) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TtfQZ-0005A6-TD for qemu-devel@nongnu.org; Fri, 11 Jan 2013 09:17:48 -0500 Received: from /spool/local by e35.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 11 Jan 2013 07:17:47 -0700 Received: from d03relay05.boulder.ibm.com (d03relay05.boulder.ibm.com [9.17.195.107]) by d03dlp01.boulder.ibm.com (Postfix) with ESMTP id 454D31FF003F for ; Fri, 11 Jan 2013 07:17:33 -0700 (MST) Received: from d03av05.boulder.ibm.com (d03av05.boulder.ibm.com [9.17.195.85]) by d03relay05.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r0BEHPLG053122 for ; Fri, 11 Jan 2013 07:17:26 -0700 Received: from d03av05.boulder.ibm.com (loopback [127.0.0.1]) by d03av05.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r0BEHP1T014722 for ; Fri, 11 Jan 2013 07:17:25 -0700 From: Anthony Liguori Date: Fri, 11 Jan 2013 08:17:15 -0600 Message-Id: <1357913836-4560-2-git-send-email-aliguori@us.ibm.com> In-Reply-To: <1357913836-4560-1-git-send-email-aliguori@us.ibm.com> References: <1357913836-4560-1-git-send-email-aliguori@us.ibm.com> Subject: [Qemu-devel] [PATCH 1/2] qdev: make reset propagation overrideable by subclasses List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , Paolo Bonzini , Anthony Liguori , Michael Tsirkin Signed-off-by: Anthony Liguori --- hw/qdev-core.h | 16 +++++++++++++++- hw/qdev.c | 11 ++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/hw/qdev-core.h b/hw/qdev-core.h index 853bd08..f40fd15 100644 --- a/hw/qdev-core.h +++ b/hw/qdev-core.h @@ -36,9 +36,23 @@ typedef struct DeviceClass { Property *props; int no_user; - /* callbacks */ + /** + * reset: + * + * Cold reset of a device. This function must be implemented by a device's + * that never have children busses. + */ void (*reset)(DeviceState *dev); + /** + * reset_all: + * + * Cold reset of a device with children. The default implementation of this + * method will invoke DeviceClass::reset and then recursively call + * qbus_reset_all() on each child in an arbitrary order. + */ + void (*reset_all)(DeviceState *dev); + /* device state */ const struct VMStateDescription *vmsd; diff --git a/hw/qdev.c b/hw/qdev.c index 1b68d02..e02b5be 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -223,11 +223,17 @@ static int qbus_reset_one(BusState *bus, void *opaque) return 0; } -void qdev_reset_all(DeviceState *dev) +static void qdev_reset_children(DeviceState *dev) { qdev_walk_children(dev, qdev_reset_one, qbus_reset_one, NULL); } +void qdev_reset_all(DeviceState *dev) +{ + DeviceClass *dc = DEVICE_GET_CLASS(dev); + dc->reset_all(dev); +} + void qbus_reset_all(BusState *bus) { qbus_walk_children(bus, qdev_reset_one, qbus_reset_one, NULL); @@ -714,7 +720,10 @@ static void device_unparent(Object *obj) static void device_class_init(ObjectClass *class, void *data) { + DeviceClass *dc = DEVICE_CLASS(class); + class->unparent = device_unparent; + dc->reset_all = qdev_reset_children; } void device_reset(DeviceState *dev) -- 1.8.0