From 5ff94a61c461111e25b67c7b9cabef035aa30225 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Fri, 26 Jul 2013 19:31:08 +0200 Subject: [PATCH] imx_avic: QOM cast cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduce type constant, use QOM casts and prepare SysBus initfn for QOM realize by resolving SysBusDevice vs. DeviceState "dev" name conflict. Acked-by: Peter Chubb Signed-off-by: Andreas Färber --- hw/intc/imx_avic.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/hw/intc/imx_avic.c b/hw/intc/imx_avic.c index 75c8ffde29..fb00e910f6 100644 --- a/hw/intc/imx_avic.c +++ b/hw/intc/imx_avic.c @@ -55,8 +55,13 @@ do { printf("imx_avic: " fmt , ##args); } while (0) #define PRIO_PER_WORD (sizeof(uint32_t) * 8 / 4) #define PRIO_WORDS (IMX_AVIC_NUM_IRQS/PRIO_PER_WORD) -typedef struct { - SysBusDevice busdev; +#define TYPE_IMX_AVIC "imx_avic" +#define IMX_AVIC(obj) \ + OBJECT_CHECK(IMXAVICState, (obj), TYPE_IMX_AVIC) + +typedef struct IMXAVICState { + SysBusDevice parent_obj; + MemoryRegion iomem; uint64_t pending; uint64_t enabled; @@ -359,7 +364,8 @@ static const MemoryRegionOps imx_avic_ops = { static void imx_avic_reset(DeviceState *dev) { - IMXAVICState *s = container_of(dev, IMXAVICState, busdev.qdev); + IMXAVICState *s = IMX_AVIC(dev); + s->pending = 0; s->enabled = 0; s->is_fiq = 0; @@ -368,17 +374,18 @@ static void imx_avic_reset(DeviceState *dev) memset(s->prio, 0, sizeof s->prio); } -static int imx_avic_init(SysBusDevice *dev) +static int imx_avic_init(SysBusDevice *sbd) { - IMXAVICState *s = FROM_SYSBUS(IMXAVICState, dev); + DeviceState *dev = DEVICE(sbd); + IMXAVICState *s = IMX_AVIC(dev); memory_region_init_io(&s->iomem, OBJECT(s), &imx_avic_ops, s, "imx_avic", 0x1000); - sysbus_init_mmio(dev, &s->iomem); + sysbus_init_mmio(sbd, &s->iomem); - qdev_init_gpio_in(&dev->qdev, imx_avic_set_irq, IMX_AVIC_NUM_IRQS); - sysbus_init_irq(dev, &s->irq); - sysbus_init_irq(dev, &s->fiq); + qdev_init_gpio_in(dev, imx_avic_set_irq, IMX_AVIC_NUM_IRQS); + sysbus_init_irq(sbd, &s->irq); + sysbus_init_irq(sbd, &s->fiq); return 0; } @@ -395,7 +402,7 @@ static void imx_avic_class_init(ObjectClass *klass, void *data) } static const TypeInfo imx_avic_info = { - .name = "imx_avic", + .name = TYPE_IMX_AVIC, .parent = TYPE_SYS_BUS_DEVICE, .instance_size = sizeof(IMXAVICState), .class_init = imx_avic_class_init,