[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH 4/5] hw/nmi: Simplify nmi_monitor_handle() and do_nmi()
From: |
Philippe Mathieu-Daudé |
Subject: |
[RFC PATCH 4/5] hw/nmi: Simplify nmi_monitor_handle() and do_nmi() |
Date: |
Thu, 16 Feb 2023 13:25:23 +0100 |
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(-)
diff --git a/hw/core/nmi.c b/hw/core/nmi.c
index fa74c405f7..f5a6483e89 100644
--- a/hw/core/nmi.c
+++ b/hw/core/nmi.c
@@ -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 = {
--
2.38.1
- [PATCH 0/5] bulk: Have object_child_foreach() take Error* and return boolean, Philippe Mathieu-Daudé, 2023/02/16
- [PATCH 1/5] hw/nmi: Have nmi_monitor_handler() return a boolean indicating error, Philippe Mathieu-Daudé, 2023/02/16
- [PATCH 2/5] spapr/ddw: Remove confuse return value in spapr_phb_get_free_liobn(), Philippe Mathieu-Daudé, 2023/02/16
- [RFC PATCH 4/5] hw/nmi: Simplify nmi_monitor_handle() and do_nmi(),
Philippe Mathieu-Daudé <=
- [PATCH 3/5] bulk: Have object_child_foreach() take Error* and return boolean, Philippe Mathieu-Daudé, 2023/02/16
- [RFC PATCH 5/5] hw/ppc/pnv_bmc: Simplify pnv_bmc_find(), Philippe Mathieu-Daudé, 2023/02/16
- Re: [RFC PATCH 5/5] hw/ppc/pnv_bmc: Simplify pnv_bmc_find(), Markus Armbruster, 2023/02/23