Patchwork [2/2] pxa2xx_pic: fixup initialisation

login
register
mail settings
Submitter Dmitry Eremin-Solenikov
Date March 4, 2011, 12:41 a.m.
Message ID <1299199260-20840-2-git-send-email-dbaryshkov@gmail.com>
Download mbox | patch
Permalink /patch/85354/
State New
Headers show

Comments

Dmitry Eremin-Solenikov - March 4, 2011, 12:41 a.m.
Currently pxa2xx_pic init fails with error at sysbus_mmio_map(),
as there is no correspondent sysbus_init_mmio. Also move most of init to
pxa2xx_pic_initfn.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 hw/pxa2xx_pic.c |   37 +++++++++++++++++++------------------
 1 files changed, 19 insertions(+), 18 deletions(-)

Patch

diff --git a/hw/pxa2xx_pic.c b/hw/pxa2xx_pic.c
index 86c0ee6..65edfd6 100644
--- a/hw/pxa2xx_pic.c
+++ b/hw/pxa2xx_pic.c
@@ -251,12 +251,25 @@  static int pxa2xx_pic_post_load(void *opaque, int version_id)
 
 DeviceState *pxa2xx_pic_init(target_phys_addr_t base, CPUState *env)
 {
-    DeviceState *dev = qdev_create(NULL, "pxa2xx_pic");
-    int iomemtype;
-    PXA2xxPICState *s = FROM_SYSBUS(PXA2xxPICState, sysbus_from_qdev(dev));
+    DeviceState *dev;
+    PXA2xxPICState *s;
+
+    dev = sysbus_create_varargs("pxa2xx_pic", base, NULL);
+    s = FROM_SYSBUS(PXA2xxPICState, sysbus_from_qdev(dev));
 
     s->cpu_env = env;
 
+    /* Enable IC coprocessor access.  */
+    cpu_arm_set_cp_io(env, 6, pxa2xx_pic_cp_read, pxa2xx_pic_cp_write, s);
+
+    return dev;
+}
+
+static int pxa2xx_pic_initfn(SysBusDevice *dev)
+{
+    PXA2xxPICState *s = FROM_SYSBUS(PXA2xxPICState, dev);
+    int iomemtype;
+
     s->int_pending[0] = 0;
     s->int_pending[1] = 0;
     s->int_enabled[0] = 0;
@@ -264,21 +277,14 @@  DeviceState *pxa2xx_pic_init(target_phys_addr_t base, CPUState *env)
     s->is_fiq[0] = 0;
     s->is_fiq[1] = 0;
 
-    qdev_init_nofail(dev);
-
-    qdev_init_gpio_in(dev, pxa2xx_pic_set_irq, PXA2XX_PIC_SRCS);
-
-    sysbus_mmio_map(sysbus_from_qdev(dev), 0, base);
+    qdev_init_gpio_in(&dev->qdev, pxa2xx_pic_set_irq, PXA2XX_PIC_SRCS);
 
     /* Enable IC memory-mapped registers access.  */
     iomemtype = cpu_register_io_memory(pxa2xx_pic_readfn,
                     pxa2xx_pic_writefn, s, DEVICE_NATIVE_ENDIAN);
-    sysbus_init_mmio(sysbus_from_qdev(dev), 0x00100000, iomemtype);
-
-    /* Enable IC coprocessor access.  */
-    cpu_arm_set_cp_io(env, 6, pxa2xx_pic_cp_read, pxa2xx_pic_cp_write, s);
+    sysbus_init_mmio(dev, 0x00100000, iomemtype);
 
-    return dev;
+    return 0;
 }
 
 static VMStateDescription vmstate_pxa2xx_pic_regs = {
@@ -297,11 +303,6 @@  static VMStateDescription vmstate_pxa2xx_pic_regs = {
     },
 };
 
-static int pxa2xx_pic_initfn(SysBusDevice *dev)
-{
-    return 0;
-}
-
 static SysBusDeviceInfo pxa2xx_pic_info = {
     .init       = pxa2xx_pic_initfn,
     .qdev.name  = "pxa2xx_pic",