omap: Don't use hw_error() in device init() methods

Device init() methods aren't supposed to call hw_error(), they should
report the error and fail cleanly.  Do that.

The errors are all device misconfiguration.  All callers use
qdev_init_nofail(), so this patch merely converts hw_error() crashes
into &error_abort crashes.  Improvement, because now it crashes closer
to where the misconfiguration bug would be, and a few more bad
examples of hw_error() use are gone.

Cc: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-Id: <1450370121-5768-3-git-send-email-armbru@redhat.com>
This commit is contained in:
Markus Armbruster 2015-12-17 17:35:10 +01:00
parent c525436e69
commit 84a3a53cf6
3 changed files with 34 additions and 13 deletions

View file

@ -20,6 +20,7 @@
#include "hw/hw.h"
#include "hw/arm/omap.h"
#include "hw/sysbus.h"
#include "qemu/error-report.h"
/* Interrupt Handlers */
struct omap_intr_handler_bank_s {
@ -367,7 +368,8 @@ static int omap_intc_init(SysBusDevice *sbd)
struct omap_intr_handler_s *s = OMAP_INTC(dev);
if (!s->iclk) {
hw_error("omap-intc: clk not connected\n");
error_report("omap-intc: clk not connected");
return -1;
}
s->nbanks = 1;
sysbus_init_irq(sbd, &s->parent_intr[0]);
@ -608,10 +610,12 @@ static int omap2_intc_init(SysBusDevice *sbd)
struct omap_intr_handler_s *s = OMAP_INTC(dev);
if (!s->iclk) {
hw_error("omap2-intc: iclk not connected\n");
error_report("omap2-intc: iclk not connected");
return -1;
}
if (!s->fclk) {
hw_error("omap2-intc: fclk not connected\n");
error_report("omap2-intc: fclk not connected");
return -1;
}
s->level_only = 1;
s->nbanks = 3;