imx_avic: QOM cast cleanup
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 <peter.chubb@nicta.com.au> Signed-off-by: Andreas Färber <afaerber@suse.de>
This commit is contained in:
parent
01774ddbcf
commit
5ff94a61c4
@ -55,8 +55,13 @@ do { printf("imx_avic: " fmt , ##args); } while (0)
|
|||||||
#define PRIO_PER_WORD (sizeof(uint32_t) * 8 / 4)
|
#define PRIO_PER_WORD (sizeof(uint32_t) * 8 / 4)
|
||||||
#define PRIO_WORDS (IMX_AVIC_NUM_IRQS/PRIO_PER_WORD)
|
#define PRIO_WORDS (IMX_AVIC_NUM_IRQS/PRIO_PER_WORD)
|
||||||
|
|
||||||
typedef struct {
|
#define TYPE_IMX_AVIC "imx_avic"
|
||||||
SysBusDevice busdev;
|
#define IMX_AVIC(obj) \
|
||||||
|
OBJECT_CHECK(IMXAVICState, (obj), TYPE_IMX_AVIC)
|
||||||
|
|
||||||
|
typedef struct IMXAVICState {
|
||||||
|
SysBusDevice parent_obj;
|
||||||
|
|
||||||
MemoryRegion iomem;
|
MemoryRegion iomem;
|
||||||
uint64_t pending;
|
uint64_t pending;
|
||||||
uint64_t enabled;
|
uint64_t enabled;
|
||||||
@ -359,7 +364,8 @@ static const MemoryRegionOps imx_avic_ops = {
|
|||||||
|
|
||||||
static void imx_avic_reset(DeviceState *dev)
|
static void imx_avic_reset(DeviceState *dev)
|
||||||
{
|
{
|
||||||
IMXAVICState *s = container_of(dev, IMXAVICState, busdev.qdev);
|
IMXAVICState *s = IMX_AVIC(dev);
|
||||||
|
|
||||||
s->pending = 0;
|
s->pending = 0;
|
||||||
s->enabled = 0;
|
s->enabled = 0;
|
||||||
s->is_fiq = 0;
|
s->is_fiq = 0;
|
||||||
@ -368,17 +374,18 @@ static void imx_avic_reset(DeviceState *dev)
|
|||||||
memset(s->prio, 0, sizeof s->prio);
|
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,
|
memory_region_init_io(&s->iomem, OBJECT(s), &imx_avic_ops, s,
|
||||||
"imx_avic", 0x1000);
|
"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);
|
qdev_init_gpio_in(dev, imx_avic_set_irq, IMX_AVIC_NUM_IRQS);
|
||||||
sysbus_init_irq(dev, &s->irq);
|
sysbus_init_irq(sbd, &s->irq);
|
||||||
sysbus_init_irq(dev, &s->fiq);
|
sysbus_init_irq(sbd, &s->fiq);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -395,7 +402,7 @@ static void imx_avic_class_init(ObjectClass *klass, void *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo imx_avic_info = {
|
static const TypeInfo imx_avic_info = {
|
||||||
.name = "imx_avic",
|
.name = TYPE_IMX_AVIC,
|
||||||
.parent = TYPE_SYS_BUS_DEVICE,
|
.parent = TYPE_SYS_BUS_DEVICE,
|
||||||
.instance_size = sizeof(IMXAVICState),
|
.instance_size = sizeof(IMXAVICState),
|
||||||
.class_init = imx_avic_class_init,
|
.class_init = imx_avic_class_init,
|
||||||
|
Loading…
Reference in New Issue
Block a user