[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 09/43] hw/intc: QOM'ify grlib_irqmp.c
From: |
Peter Maydell |
Subject: |
[Qemu-devel] [PULL 09/43] hw/intc: QOM'ify grlib_irqmp.c |
Date: |
Thu, 12 May 2016 14:32:31 +0100 |
From: "xiaoqiang.zhao" <address@hidden>
* Split the old SysBus init into an instance_init and a
DeviceClass::realize function
* Drop the old SysBus init function
Signed-off-by: xiaoqiang zhao <address@hidden>
Reviewed-by: Peter Maydell <address@hidden>
[PMM: corrected "can not" to "cannot" in error message]
Signed-off-by: Peter Maydell <address@hidden>
---
hw/intc/grlib_irqmp.c | 27 ++++++++++++++++-----------
1 file changed, 16 insertions(+), 11 deletions(-)
diff --git a/hw/intc/grlib_irqmp.c b/hw/intc/grlib_irqmp.c
index f5ca8f7..ac7e63f 100644
--- a/hw/intc/grlib_irqmp.c
+++ b/hw/intc/grlib_irqmp.c
@@ -31,6 +31,7 @@
#include "hw/sparc/grlib.h"
#include "trace.h"
+#include "qapi/error.h"
#define IRQMP_MAX_CPU 16
#define IRQMP_REG_SIZE 256 /* Size of memory mapped registers */
@@ -323,23 +324,27 @@ static void grlib_irqmp_reset(DeviceState *d)
irqmp->state->parent = irqmp;
}
-static int grlib_irqmp_init(SysBusDevice *dev)
+static void grlib_irqmp_init(Object *obj)
{
- IRQMP *irqmp = GRLIB_IRQMP(dev);
-
- /* Check parameters */
- if (irqmp->set_pil_in == NULL) {
- return -1;
- }
+ IRQMP *irqmp = GRLIB_IRQMP(obj);
+ SysBusDevice *dev = SYS_BUS_DEVICE(obj);
- memory_region_init_io(&irqmp->iomem, OBJECT(dev), &grlib_irqmp_ops, irqmp,
+ memory_region_init_io(&irqmp->iomem, obj, &grlib_irqmp_ops, irqmp,
"irqmp", IRQMP_REG_SIZE);
irqmp->state = g_malloc0(sizeof *irqmp->state);
sysbus_init_mmio(dev, &irqmp->iomem);
+}
- return 0;
+static void grlib_irqmp_realize(DeviceState *dev, Error **errp)
+{
+ IRQMP *irqmp = GRLIB_IRQMP(dev);
+
+ /* Check parameters */
+ if (irqmp->set_pil_in == NULL) {
+ error_setg(errp, "set_pil_in cannot be NULL.");
+ }
}
static Property grlib_irqmp_properties[] = {
@@ -351,19 +356,19 @@ static Property grlib_irqmp_properties[] = {
static void grlib_irqmp_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
- SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
- k->init = grlib_irqmp_init;
dc->reset = grlib_irqmp_reset;
dc->props = grlib_irqmp_properties;
/* Reason: pointer properties "set_pil_in", "set_pil_in_opaque" */
dc->cannot_instantiate_with_device_add_yet = true;
+ dc->realize = grlib_irqmp_realize;
}
static const TypeInfo grlib_irqmp_info = {
.name = TYPE_GRLIB_IRQMP,
.parent = TYPE_SYS_BUS_DEVICE,
.instance_size = sizeof(IRQMP),
+ .instance_init = grlib_irqmp_init,
.class_init = grlib_irqmp_class_init,
};
--
1.9.1
- [Qemu-devel] [PULL 03/43] hw/intc: QOM'ify etraxfs_pic.c, (continued)
- [Qemu-devel] [PULL 03/43] hw/intc: QOM'ify etraxfs_pic.c, Peter Maydell, 2016/05/12
- [Qemu-devel] [PULL 39/43] hw/arm: QOM'ify pxa2xx_pic.c, Peter Maydell, 2016/05/12
- [Qemu-devel] [PULL 33/43] hw/display/blizzard: Remove blizzard_template.h, Peter Maydell, 2016/05/12
- [Qemu-devel] [PULL 38/43] hw/arm: QOM'ify pxa2xx.c, Peter Maydell, 2016/05/12
- [Qemu-devel] [PULL 10/43] hw/intc: QOM'ify omap_intc.c, Peter Maydell, 2016/05/12
- [Qemu-devel] [PULL 34/43] target-arm: Avoid unnecessary TLB flush on TCR_EL2, TCR_EL3 writes, Peter Maydell, 2016/05/12
- [Qemu-devel] [PULL 36/43] hw/arm: QOM'ify highbank.c, Peter Maydell, 2016/05/12
- [Qemu-devel] [PULL 43/43] hw/arm: QOM'ify versatilepb.c, Peter Maydell, 2016/05/12
- [Qemu-devel] [PULL 41/43] hw/arm: QOM'ify stellaris.c, Peter Maydell, 2016/05/12
- [Qemu-devel] [PULL 26/43] ARM: Factor out ARM on/off PSCI control functions, Peter Maydell, 2016/05/12
- [Qemu-devel] [PULL 09/43] hw/intc: QOM'ify grlib_irqmp.c,
Peter Maydell <=
- [Qemu-devel] [PULL 21/43] ARM: Virt: Set numa-node-id for cpu and memory nodes, Peter Maydell, 2016/05/12
- [Qemu-devel] [PULL 30/43] i.MX: Add i.MX6 SOC implementation., Peter Maydell, 2016/05/12
- [Qemu-devel] [PULL 42/43] hw/arm: QOM'ify strongarm.c, Peter Maydell, 2016/05/12
- [Qemu-devel] [PULL 40/43] hw/arm: QOM'ify spitz.c, Peter Maydell, 2016/05/12
- Re: [Qemu-devel] [PULL 00/43] target-arm queue, Peter Maydell, 2016/05/12