qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <aliguori@us.ibm.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Anthony Liguori <aliguori@us.ibm.com>,
	Michael Tsirkin <mst@redhat.com>
Subject: [Qemu-devel] [PATCH 2/2] qbus: make bus reset overrideable by subclasses
Date: Fri, 11 Jan 2013 08:17:16 -0600	[thread overview]
Message-ID: <1357913836-4560-3-git-send-email-aliguori@us.ibm.com> (raw)
In-Reply-To: <1357913836-4560-1-git-send-email-aliguori@us.ibm.com>

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
 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,
-- 
1.8.0

  parent reply	other threads:[~2013-01-11 14:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-11 14:17 [Qemu-devel] [PATCH 0/2] qdev: make reset propagation overrideable by subclasses Anthony Liguori
2013-01-11 14:17 ` [Qemu-devel] [PATCH 1/2] " Anthony Liguori
2013-01-11 14:48   ` Andreas Färber
2013-01-11 14:17 ` Anthony Liguori [this message]
2013-01-11 14:21   ` [Qemu-devel] [PATCH 2/2] qbus: make bus reset " Paolo Bonzini
2013-01-11 14:48     ` Anthony Liguori

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1357913836-4560-3-git-send-email-aliguori@us.ibm.com \
    --to=aliguori@us.ibm.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).