@@ -26,51 +26,22 @@
#include "qemu/module.h"
#include "monitor/monitor.h"
-struct do_nmi_s {
- int cpu_index;
- Error *err;
- bool handled;
-};
-
-static void nmi_children(Object *o, struct do_nmi_s *ns);
-
static bool do_nmi(Object *o, void *opaque, Error **errp)
{
- struct do_nmi_s *ns = opaque;
+ int *cpu_index = opaque;
NMIState *n = (NMIState *) object_dynamic_cast(o, TYPE_NMI);
- if (n) {
- NMIClass *nc = NMI_GET_CLASS(n);
-
- ns->handled = true;
- if (!nc->nmi_monitor_handler(n, ns->cpu_index, &ns->err)) {
- return false;
- }
+ if (!n) {
+ error_setg(errp, QERR_UNSUPPORTED);
+ return false;
}
- nmi_children(o, ns);
- return true;
-}
-
-static void nmi_children(Object *o, struct do_nmi_s *ns)
-{
- object_child_foreach(o, do_nmi, ns, NULL);
+ return NMI_GET_CLASS(n)->nmi_monitor_handler(n, *cpu_index, errp);
}
void nmi_monitor_handle(int cpu_index, Error **errp)
{
- struct do_nmi_s ns = {
- .cpu_index = cpu_index,
- .err = NULL,
- .handled = false
- };
-
- nmi_children(object_get_root(), &ns);
- if (ns.handled) {
- error_propagate(errp, ns.err);
- } else {
- error_setg(errp, QERR_UNSUPPORTED);
- }
+ object_child_foreach_recursive(object_get_root(), do_nmi, &cpu_index, errp);
}
static const TypeInfo nmi_info = {
Since the previous commit, object_child_foreach_recursive()'s handler takes an Error* argument and return a boolean. We can remove these fields from the do_nmi_s structure, which then only contains the 'int cpu_index' field. Directly pass 'cpu_index' as context, removing 'struct do_nmi_s'. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> --- RFC: please double-check... hw/core/nmi.c | 41 ++++++----------------------------------- 1 file changed, 6 insertions(+), 35 deletions(-)