From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:57491) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TtfuU-0003Aa-Qr for qemu-devel@nongnu.org; Fri, 11 Jan 2013 09:48:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TtfuO-0005RN-8Y for qemu-devel@nongnu.org; Fri, 11 Jan 2013 09:48:42 -0500 Received: from e8.ny.us.ibm.com ([32.97.182.138]:54536) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TtfuO-0005RJ-4S for qemu-devel@nongnu.org; Fri, 11 Jan 2013 09:48:36 -0500 Received: from /spool/local by e8.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 11 Jan 2013 09:48:34 -0500 Received: from d01relay01.pok.ibm.com (d01relay01.pok.ibm.com [9.56.227.233]) by d01dlp01.pok.ibm.com (Postfix) with ESMTP id E22B838C803B for ; Fri, 11 Jan 2013 09:48:16 -0500 (EST) Received: from d01av04.pok.ibm.com (d01av04.pok.ibm.com [9.56.224.64]) by d01relay01.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r0BEmGVT286942 for ; Fri, 11 Jan 2013 09:48:16 -0500 Received: from d01av04.pok.ibm.com (loopback [127.0.0.1]) by d01av04.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r0BEmGse010329 for ; Fri, 11 Jan 2013 09:48:16 -0500 From: Anthony Liguori In-Reply-To: <50F01FD6.6030408@redhat.com> References: <1357913836-4560-1-git-send-email-aliguori@us.ibm.com> <1357913836-4560-3-git-send-email-aliguori@us.ibm.com> <50F01FD6.6030408@redhat.com> Date: Fri, 11 Jan 2013 08:48:11 -0600 Message-ID: <877gnjsrmc.fsf@codemonkey.ws> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [Qemu-devel] [PATCH 2/2] qbus: make bus reset overrideable by subclasses List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: Peter Maydell , qemu-devel@nongnu.org, Michael Tsirkin Paolo Bonzini writes: > Il 11/01/2013 15:17, Anthony Liguori ha scritto: >> 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, >> > > Once you do this, the return value of bus->reset should become void, and > classes that used to return 1 should instead override reset_all. Can > you do that too? Sure. Regards, Anthony Liguori > > Paolo