Not a single handler update @errp. The single user is nmi_trigger() filling with "machine does not provide NMIs". Remove the unused argument from the deliver_nmi() callback, simplifying the methods in hw/core/nmi.c.
Signed-off-by: Philippe Mathieu-Daudé <[email protected]> --- include/hw/core/nmi.h | 3 +-- hw/core/nmi.c | 32 ++++++-------------------------- hw/hppa/machine.c | 2 +- hw/i386/x86.c | 2 +- hw/intc/m68k_irqc.c | 2 +- hw/m68k/q800-glue.c | 2 +- hw/misc/macio/gpio.c | 2 +- hw/ppc/pnv.c | 2 +- hw/ppc/spapr.c | 2 +- hw/s390x/s390-virtio-ccw.c | 2 +- 10 files changed, 15 insertions(+), 36 deletions(-) diff --git a/include/hw/core/nmi.h b/include/hw/core/nmi.h index d6bd2a9fceb..b0f58542bcc 100644 --- a/include/hw/core/nmi.h +++ b/include/hw/core/nmi.h @@ -41,9 +41,8 @@ struct NMIClass { * deliver_nmi: Callback to handle NMI notifications. * * @ns: Class #NMIState state - * @errp: pointer to error object */ - void (*deliver_nmi)(NMIState *ns, Error **errp); + void (*deliver_nmi)(NMIState *ns); }; /** diff --git a/hw/core/nmi.c b/hw/core/nmi.c index 02c0ff2c21d..8eea75ad530 100644 --- a/hw/core/nmi.c +++ b/hw/core/nmi.c @@ -23,45 +23,25 @@ #include "hw/core/nmi.h" #include "qapi/error.h" -struct do_nmi_s { - Error *err; - bool handled; -}; - static int do_nmi(Object *o, void *opaque) { - struct do_nmi_s *ns = opaque; + bool *handled = opaque; NMIState *n = (NMIState *) object_dynamic_cast(o, TYPE_NMI); if (n) { - NMIClass *nc = NMI_GET_CLASS(n); - - ns->handled = true; - nc->deliver_nmi(n, &ns->err); - if (ns->err) { - return -1; - } + *handled = true; + NMI_GET_CLASS(n)->deliver_nmi(n); } return 0; } -static int nmi_children(Object *o, struct do_nmi_s *ns) -{ - return object_child_foreach_recursive(o, do_nmi, ns); -} - bool nmi_trigger(Error **errp) { - struct do_nmi_s ns = { - .err = NULL, - .handled = false - }; + bool handled = false; - if (nmi_children(object_get_root(), &ns)) { - error_propagate(errp, ns.err); - return false; - } else if (!ns.handled) { + object_child_foreach_recursive(object_get_root(), do_nmi, &handled); + if (!handled) { error_setg(errp, "machine does not provide NMIs"); return false; } diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c index 47e0302bac8..51ecdabdbd5 100644 --- a/hw/hppa/machine.c +++ b/hw/hppa/machine.c @@ -829,7 +829,7 @@ static void hppa_machine_reset(MachineState *ms, ResetType type) cpu[0]->env.cmdline_or_bootorder = 'c'; } -static void hppa_nmi(NMIState *ns, Error **errp) +static void hppa_nmi(NMIState *ns) { CPUState *cs; diff --git a/hw/i386/x86.c b/hw/i386/x86.c index 48f7575895a..8d82bd890da 100644 --- a/hw/i386/x86.c +++ b/hw/i386/x86.c @@ -147,7 +147,7 @@ static const CPUArchIdList *x86_possible_cpu_arch_ids(MachineState *ms) return ms->possible_cpus; } -static void x86_nmi(NMIState *ns, Error **errp) +static void x86_nmi(NMIState *ns) { /* cpu index isn't used */ CPUState *cs; diff --git a/hw/intc/m68k_irqc.c b/hw/intc/m68k_irqc.c index 281542e3997..b78ca5ca11b 100644 --- a/hw/intc/m68k_irqc.c +++ b/hw/intc/m68k_irqc.c @@ -70,7 +70,7 @@ static void m68k_irqc_instance_init(Object *obj) qdev_init_gpio_in(DEVICE(obj), m68k_set_irq, M68K_IRQC_LEVEL_NUM); } -static void m68k_nmi(NMIState *n, Error **errp) +static void m68k_nmi(NMIState *n) { m68k_set_irq(n, M68K_IRQC_LEVEL_7, 1); } diff --git a/hw/m68k/q800-glue.c b/hw/m68k/q800-glue.c index b75f7f44d3c..8be7696777e 100644 --- a/hw/m68k/q800-glue.c +++ b/hw/m68k/q800-glue.c @@ -159,7 +159,7 @@ static void glue_auxmode_set_irq(void *opaque, int irq, int level) s->auxmode = level; } -static void glue_nmi(NMIState *n, Error **errp) +static void glue_nmi(NMIState *n) { GLUEState *s = GLUE(n); diff --git a/hw/misc/macio/gpio.c b/hw/misc/macio/gpio.c index 086d90f20b6..ba4df62c674 100644 --- a/hw/misc/macio/gpio.c +++ b/hw/misc/macio/gpio.c @@ -188,7 +188,7 @@ static void macio_gpio_reset(DeviceState *dev) macio_set_gpio(s, 1, true); } -static void macio_gpio_nmi(NMIState *n, Error **errp) +static void macio_gpio_nmi(NMIState *n) { macio_set_gpio(MACIO_GPIO(n), 9, true); macio_set_gpio(MACIO_GPIO(n), 9, false); diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index bfb1d45d058..2ec0c198fa5 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -3552,7 +3552,7 @@ static void pnv_cpu_do_nmi(PnvChip *chip, PowerPCCPU *cpu, void *opaque) async_run_on_cpu(CPU(cpu), pnv_cpu_do_nmi_on_cpu, RUN_ON_CPU_HOST_INT(0)); } -static void pnv_nmi(NMIState *ns, Error **errp) +static void pnv_nmi(NMIState *ns) { PnvMachineState *pnv = PNV_MACHINE(qdev_get_machine()); int i; diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index ed545acf3c0..477054d8c85 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3550,7 +3550,7 @@ void spapr_do_system_reset_on_cpu(CPUState *cs, run_on_cpu_data arg) } } -static void spapr_nmi(NMIState *ns, Error **errp) +static void spapr_nmi(NMIState *ns) { CPUState *cs; diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index f9e8ecb4fe0..255698fd7ed 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -725,7 +725,7 @@ static HotplugHandler *s390_get_hotplug_handler(MachineState *machine, return NULL; } -static void s390_nmi(NMIState *ns, Error **errp) +static void s390_nmi(NMIState *ns) { s390_cpu_restart(S390_CPU(first_cpu)); } -- 2.53.0
