[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 046/173] pxa2xx: QOM cast cleanup for PXA2xxI2CState
From: |
Andreas Färber |
Subject: |
[Qemu-devel] [PULL 046/173] pxa2xx: QOM cast cleanup for PXA2xxI2CState |
Date: |
Mon, 29 Jul 2013 21:18:23 +0200 |
Introduce a type constant, use QOM casts, rename the parent field and
prepare for QOM realize.
Signed-off-by: Andreas Färber <address@hidden>
---
hw/arm/pxa2xx.c | 34 +++++++++++++++++++++-------------
1 file changed, 21 insertions(+), 13 deletions(-)
diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c
index 6548338..7de6453 100644
--- a/hw/arm/pxa2xx.c
+++ b/hw/arm/pxa2xx.c
@@ -1224,8 +1224,15 @@ typedef struct {
PXA2xxI2CState *host;
} PXA2xxI2CSlaveState;
+#define TYPE_PXA2XX_I2C "pxa2xx_i2c"
+#define PXA2XX_I2C(obj) \
+ OBJECT_CHECK(PXA2xxI2CState, (obj), TYPE_PXA2XX_I2C)
+
struct PXA2xxI2CState {
- SysBusDevice busdev;
+ /*< private >*/
+ SysBusDevice parent_obj;
+ /*< public >*/
+
MemoryRegion iomem;
PXA2xxI2CSlaveState *slave;
i2c_bus *bus;
@@ -1473,16 +1480,16 @@ PXA2xxI2CState *pxa2xx_i2c_init(hwaddr base,
SysBusDevice *i2c_dev;
PXA2xxI2CState *s;
- i2c_dev = SYS_BUS_DEVICE(qdev_create(NULL, "pxa2xx_i2c"));
- qdev_prop_set_uint32(&i2c_dev->qdev, "size", region_size + 1);
- qdev_prop_set_uint32(&i2c_dev->qdev, "offset", base & region_size);
-
- qdev_init_nofail(&i2c_dev->qdev);
+ dev = qdev_create(NULL, TYPE_PXA2XX_I2C);
+ qdev_prop_set_uint32(dev, "size", region_size + 1);
+ qdev_prop_set_uint32(dev, "offset", base & region_size);
+ qdev_init_nofail(dev);
+ i2c_dev = SYS_BUS_DEVICE(dev);
sysbus_mmio_map(i2c_dev, 0, base & ~region_size);
sysbus_connect_irq(i2c_dev, 0, irq);
- s = FROM_SYSBUS(PXA2xxI2CState, i2c_dev);
+ s = PXA2XX_I2C(i2c_dev);
/* FIXME: Should the slave device really be on a separate bus? */
dev = i2c_create_slave(i2c_init_bus(NULL, "dummy"), "pxa2xx-i2c-slave", 0);
s->slave = FROM_I2C_SLAVE(PXA2xxI2CSlaveState, I2C_SLAVE(dev));
@@ -1491,16 +1498,17 @@ PXA2xxI2CState *pxa2xx_i2c_init(hwaddr base,
return s;
}
-static int pxa2xx_i2c_initfn(SysBusDevice *dev)
+static int pxa2xx_i2c_initfn(SysBusDevice *sbd)
{
- PXA2xxI2CState *s = FROM_SYSBUS(PXA2xxI2CState, dev);
+ DeviceState *dev = DEVICE(sbd);
+ PXA2xxI2CState *s = PXA2XX_I2C(dev);
- s->bus = i2c_init_bus(&dev->qdev, "i2c");
+ s->bus = i2c_init_bus(dev, "i2c");
memory_region_init_io(&s->iomem, OBJECT(s), &pxa2xx_i2c_ops, s,
"pxa2xx-i2c", s->region_size);
- sysbus_init_mmio(dev, &s->iomem);
- sysbus_init_irq(dev, &s->irq);
+ sysbus_init_mmio(sbd, &s->iomem);
+ sysbus_init_irq(sbd, &s->irq);
return 0;
}
@@ -1528,7 +1536,7 @@ static void pxa2xx_i2c_class_init(ObjectClass *klass,
void *data)
}
static const TypeInfo pxa2xx_i2c_info = {
- .name = "pxa2xx_i2c",
+ .name = TYPE_PXA2XX_I2C,
.parent = TYPE_SYS_BUS_DEVICE,
.instance_size = sizeof(PXA2xxI2CState),
.class_init = pxa2xx_i2c_class_init,
--
1.8.1.4
- [Qemu-devel] [PULL 035/173] integratorcp: QOM cast cleanup for icp_pic_state, (continued)
- [Qemu-devel] [PULL 035/173] integratorcp: QOM cast cleanup for icp_pic_state, Andreas Färber, 2013/07/29
- [Qemu-devel] [PULL 037/173] musicpal: QOM cast cleanup for mv88w8618_eth_state, Andreas Färber, 2013/07/29
- [Qemu-devel] [PULL 038/173] musicpal: QOM cast cleanup for musicpal_lcd_state, Andreas Färber, 2013/07/29
- [Qemu-devel] [PULL 039/173] musicpal: QOM cast cleanup mv88w8618_pic_state, Andreas Färber, 2013/07/29
- [Qemu-devel] [PULL 040/173] musicpal: QOM cast cleanup for mv88w8618_pit_state, Andreas Färber, 2013/07/29
- [Qemu-devel] [PULL 041/173] musicpal: QOM cast cleanup for mv88w8618_flashcfg, Andreas Färber, 2013/07/29
- [Qemu-devel] [PULL 042/173] musicpal: QOM cast cleanup for musicpal_gpio_state, Andreas Färber, 2013/07/29
- [Qemu-devel] [PULL 043/173] musicpal: QOM cast cleanup for musicpal_key_state, Andreas Färber, 2013/07/29
- [Qemu-devel] [PULL 044/173] pxa2xx: QOM cast cleanup for PXA2xxSSPState, Andreas Färber, 2013/07/29
- [Qemu-devel] [PULL 045/173] pxa2xx: QOM cast cleanup for PXA2xxRTCState, Andreas Färber, 2013/07/29
- [Qemu-devel] [PULL 046/173] pxa2xx: QOM cast cleanup for PXA2xxI2CState,
Andreas Färber <=
- [Qemu-devel] [PULL 047/173] pxa2xx_gpio: QOM cast cleanup for PXA2xxGPIOInfo, Andreas Färber, 2013/07/29
- [Qemu-devel] [PULL 048/173] pxa2xx_pic: QOM cast cleanup for PXA2xxPICState, Andreas Färber, 2013/07/29
- [Qemu-devel] [PULL 050/173] spitz: QOM cast cleanup for SpitzKeyboardState, Andreas Färber, 2013/07/29
- [Qemu-devel] [PULL 049/173] spitz: QOM cast cleanup for SLNANDState, Andreas Färber, 2013/07/29
- [Qemu-devel] [PULL 051/173] stellaris: QOM cast cleanup for gptm_state, Andreas Färber, 2013/07/29
- [Qemu-devel] [PULL 052/173] stellaris: QOM cast cleanup for stellaris_i2c_state, Andreas Färber, 2013/07/29
- [Qemu-devel] [PULL 053/173] stellaris: QOM cast cleanup for stellaris_adc_state, Andreas Färber, 2013/07/29
- [Qemu-devel] [PULL 054/173] strongarm: QOM cast cleanup for StrongARMPICState, Andreas Färber, 2013/07/29
- [Qemu-devel] [PULL 055/173] strongarm: QOM cast cleanup for StrongARMRTCState, Andreas Färber, 2013/07/29
- [Qemu-devel] [PULL 056/173] strongarm: QOM cast cleanup for StrongARMGPIOInfo, Andreas Färber, 2013/07/29