From patchwork Fri Jan 11 14:17:16 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony Liguori X-Patchwork-Id: 211356 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 0F1D72C01E6 for ; Sat, 12 Jan 2013 01:17:48 +1100 (EST) Received: from localhost ([::1]:50448 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TtfQY-0006Pw-4e for incoming@patchwork.ozlabs.org; Fri, 11 Jan 2013 09:17:46 -0500 Received: from eggs.gnu.org ([208.118.235.92]:49449) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TtfQO-0006PU-02 for qemu-devel@nongnu.org; Fri, 11 Jan 2013 09:17:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TtfQL-00057c-TU for qemu-devel@nongnu.org; Fri, 11 Jan 2013 09:17:35 -0500 Received: from e9.ny.us.ibm.com ([32.97.182.139]:49692) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TtfQL-00057U-PI for qemu-devel@nongnu.org; Fri, 11 Jan 2013 09:17:33 -0500 Received: from /spool/local by e9.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 11 Jan 2013 09:17:33 -0500 Received: from d01dlp02.pok.ibm.com (9.56.250.167) by e9.ny.us.ibm.com (192.168.1.109) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 11 Jan 2013 09:17:30 -0500 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by d01dlp02.pok.ibm.com (Postfix) with ESMTP id 3F8996E803F for ; Fri, 11 Jan 2013 09:17:28 -0500 (EST) Received: from d03av05.boulder.ibm.com (d03av05.boulder.ibm.com [9.17.195.85]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r0BEHRrD181226 for ; Fri, 11 Jan 2013 09:17:27 -0500 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 r0BEHQc1014807 for ; Fri, 11 Jan 2013 07:17:26 -0700 Received: from titi.austin.rr.com ([9.49.216.248]) by d03av05.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r0BEHMuv014543; Fri, 11 Jan 2013 07:17:25 -0700 From: Anthony Liguori To: qemu-devel@nongnu.org Date: Fri, 11 Jan 2013 08:17:16 -0600 Message-Id: <1357913836-4560-3-git-send-email-aliguori@us.ibm.com> X-Mailer: git-send-email 1.8.0 In-Reply-To: <1357913836-4560-1-git-send-email-aliguori@us.ibm.com> References: <1357913836-4560-1-git-send-email-aliguori@us.ibm.com> X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13011114-7182-0000-0000-0000045B7CAD X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 32.97.182.139 Cc: Peter Maydell , Paolo Bonzini , Anthony Liguori , Michael Tsirkin Subject: [Qemu-devel] [PATCH 2/2] qbus: make bus reset overrideable by 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 Signed-off-by: Anthony Liguori --- hw/qdev-core.h | 15 +++++++++++++++ hw/qdev.c | 16 +++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/hw/qdev-core.h b/hw/qdev-core.h index f40fd15..453a061 100644 --- a/hw/qdev-core.h +++ b/hw/qdev-core.h @@ -100,7 +100,22 @@ struct BusClass { * bindings can be found at http://playground.sun.com/1275/bindings/. */ char *(*get_fw_dev_path)(DeviceState *dev); + + /** + * reset: + * + * Cold reset of a bus. This only resets the controller state of the bus. + */ int (*reset)(BusState *bus); + + /** + * reset_all: + * + * Cold reset of a bus with children. The default implementation of this + * method will invoke BusState::reset and then recursively call + * qdev_reset_all() on each child in an arbitrary order. + */ + void (*reset_all)(BusState *bus); }; typedef struct BusChild { diff --git a/hw/qdev.c b/hw/qdev.c index e02b5be..db19b14 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -234,11 +234,17 @@ void qdev_reset_all(DeviceState *dev) dc->reset_all(dev); } -void qbus_reset_all(BusState *bus) +static void qbus_reset_children(BusState *bus) { qbus_walk_children(bus, qdev_reset_one, qbus_reset_one, NULL); } +void qbus_reset_all(BusState *bus) +{ + BusClass *bc = BUS_GET_CLASS(bus); + bc->reset_all(bus); +} + void qbus_reset_all_fn(void *opaque) { BusState *bus = opaque; @@ -758,6 +764,13 @@ static const TypeInfo device_type_info = { .class_size = sizeof(DeviceClass), }; +static void qbus_class_initfn(ObjectClass *klass, void *data) +{ + BusClass *bc = BUS_CLASS(klass); + + bc->reset_all = qbus_reset_children; +} + static void qbus_initfn(Object *obj) { BusState *bus = BUS(obj); @@ -789,6 +802,7 @@ static const TypeInfo bus_info = { .parent = TYPE_OBJECT, .instance_size = sizeof(BusState), .abstract = true, + .class_init = qbus_class_initfn, .class_size = sizeof(BusClass), .instance_init = qbus_initfn, .instance_finalize = qbus_finalize,