Patchwork [2/6] qdev: introduce reset call back for qbus level.

login
register
mail settings
Submitter Isaku Yamahata
Date Sept. 2, 2010, 9:25 a.m.
Message ID <5b44fda814a73ac84c177db21bad6e1c4526b38a.1283417726.git.yamahata@valinux.co.jp>
Download mbox | patch
Permalink /patch/63460/
State New
Headers show

Comments

Isaku Yamahata - Sept. 2, 2010, 9:25 a.m.
and make it called via qbus_reset_all().
The qbus reset callback will be used by pci bus reset.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
---
 hw/qdev-core.h |    3 +++
 hw/qdev.c      |   10 +++++++++-
 2 files changed, 12 insertions(+), 1 deletions(-)

Patch

diff --git a/hw/qdev-core.h b/hw/qdev-core.h
index a9b7692..49ac87a 100644
--- a/hw/qdev-core.h
+++ b/hw/qdev-core.h
@@ -58,12 +58,15 @@  typedef int (qbus_del_devfn)(BusState *bus, DeviceState *dev);
 
 typedef void (qbus_realizefn)(BusState *bus);
 
+typedef int (qbus_resetfn)(BusState *bus);
+
 struct BusInfo {
     const char *name;
     size_t size;
     qbus_add_devfn *add_dev;
     qbus_del_devfn *del_dev;
     qbus_realizefn *realize;
+    qbus_resetfn *reset;
     bus_get_dev_path get_dev_path;
     Property *props;
 };
diff --git a/hw/qdev.c b/hw/qdev.c
index c1ba6b8..9300d7f 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -166,9 +166,17 @@  static int qdev_reset_one(DeviceState *dev, void *opaque)
     return 0;
 }
 
+static int qbus_reset_one(BusState *bus, void *opaque)
+{
+    if (bus->info->reset) {
+        return bus->info->reset(bus);
+    }
+    return 0;
+}
+
 void qbus_reset_all(BusState *bus)
 {
-    qbus_walk_children(bus, qdev_reset_one, NULL, NULL);
+    qbus_walk_children(bus, qdev_reset_one, qbus_reset_one, NULL);
 }
 
 static int qdev_realize_one(DeviceState *dev, void *opaque)