Patchwork [08/12] qdev: move reset register/unregister code to qdev-system.c

login
register
mail settings
Submitter Eduardo Habkost
Date Oct. 16, 2012, 7:08 p.m.
Message ID <1350414523-8117-9-git-send-email-ehabkost@redhat.com>
Download mbox | patch
Permalink /patch/191871/
State New
Headers show

Comments

Eduardo Habkost - Oct. 16, 2012, 7:08 p.m.
Also, add weak symbols that will be used if qdev-system.o is not
compiled in (i.e. on *-user).

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Changes v1 -> v2:
 - Add GCC_WEAK_DECL to function declarations
---
 hw/qdev-core.c   | 16 +++++++---------
 hw/qdev-core.h   |  3 +++
 hw/qdev-system.c | 15 +++++++++++++++
 3 files changed, 25 insertions(+), 9 deletions(-)

Patch

diff --git a/hw/qdev-core.c b/hw/qdev-core.c
index a105679..a756e07 100644
--- a/hw/qdev-core.c
+++ b/hw/qdev-core.c
@@ -47,19 +47,17 @@  void GCC_WEAK qdev_finalize_vmstate(DeviceState *dev)
 {
 }
 
-static void qbus_register_reset(BusState *bus)
+/* reset handler register/unregister:
+ *
+ * The real implementations are on qdev-system.c. Those are weak symbols
+ * used by *-user.
+ */
+void GCC_WEAK qbus_register_reset(BusState *bus)
 {
-    if (bus != sysbus_get_default()) {
-        /* TODO: once all bus devices are qdevified,
-           only reset handler for main_system_bus should be registered here. */
-        qemu_register_reset(qbus_reset_all_fn, bus);
-    }
 }
 
-static void qbus_unregister_reset(BusState *bus)
+void GCC_WEAK qbus_unregister_reset(BusState *bus)
 {
-    assert(bus != sysbus_get_default()); /* main_system_bus is never freed */
-    qemu_unregister_reset(qbus_reset_all_fn, bus);
 }
 
 const char *qdev_fw_name(DeviceState *dev)
diff --git a/hw/qdev-core.h b/hw/qdev-core.h
index 89c54d5..e030fff 100644
--- a/hw/qdev-core.h
+++ b/hw/qdev-core.h
@@ -226,6 +226,9 @@  const struct VMStateDescription *qdev_get_vmsd(DeviceState *dev);
 void GCC_WEAK_DECL qdev_init_vmstate(DeviceState *dev);
 void GCC_WEAK_DECL qdev_finalize_vmstate(DeviceState *dev);
 
+void GCC_WEAK_DECL qbus_register_reset(BusState *bus);
+void GCC_WEAK_DECL qbus_unregister_reset(BusState *bus);
+
 const char *qdev_fw_name(DeviceState *dev);
 
 Object *qdev_get_machine(void);
diff --git a/hw/qdev-system.c b/hw/qdev-system.c
index 0c00ab3..21074a0 100644
--- a/hw/qdev-system.c
+++ b/hw/qdev-system.c
@@ -88,3 +88,18 @@  void qdev_finalize_vmstate(DeviceState *dev)
         vmstate_unregister(dev, qdev_get_vmsd(dev), dev);
     }
 }
+
+void qbus_register_reset(BusState *bus)
+{
+    if (bus != sysbus_get_default()) {
+        /* TODO: once all bus devices are qdevified,
+           only reset handler for main_system_bus should be registered here. */
+        qemu_register_reset(qbus_reset_all_fn, bus);
+    }
+}
+
+void qbus_unregister_reset(BusState *bus)
+{
+    assert(bus != sysbus_get_default()); /* main_system_bus is never freed */
+    qemu_unregister_reset(qbus_reset_all_fn, bus);
+}