strongarm: QOM cast cleanup for StrongARMUARTState

Introduce a type constant, use QOM casts and rename the parent field.

Signed-off-by: Andreas Färber <afaerber@suse.de>
This commit is contained in:
Andreas Färber 2013-07-24 09:29:14 +02:00
parent c71e673291
commit fff3af97b9

View File

@ -908,8 +908,13 @@ static const TypeInfo strongarm_ppc_info = {
#define RX_FIFO_FRE (1 << 9) #define RX_FIFO_FRE (1 << 9)
#define RX_FIFO_ROR (1 << 10) #define RX_FIFO_ROR (1 << 10)
typedef struct { #define TYPE_STRONGARM_UART "strongarm-uart"
SysBusDevice busdev; #define STRONGARM_UART(obj) \
OBJECT_CHECK(StrongARMUARTState, (obj), TYPE_STRONGARM_UART)
typedef struct StrongARMUARTState {
SysBusDevice parent_obj;
MemoryRegion iomem; MemoryRegion iomem;
CharDriverState *chr; CharDriverState *chr;
qemu_irq irq; qemu_irq irq;
@ -1225,7 +1230,7 @@ static const MemoryRegionOps strongarm_uart_ops = {
static int strongarm_uart_init(SysBusDevice *dev) static int strongarm_uart_init(SysBusDevice *dev)
{ {
StrongARMUARTState *s = FROM_SYSBUS(StrongARMUARTState, dev); StrongARMUARTState *s = STRONGARM_UART(dev);
memory_region_init_io(&s->iomem, OBJECT(s), &strongarm_uart_ops, s, memory_region_init_io(&s->iomem, OBJECT(s), &strongarm_uart_ops, s,
"uart", 0x10000); "uart", 0x10000);
@ -1248,7 +1253,7 @@ static int strongarm_uart_init(SysBusDevice *dev)
static void strongarm_uart_reset(DeviceState *dev) static void strongarm_uart_reset(DeviceState *dev)
{ {
StrongARMUARTState *s = DO_UPCAST(StrongARMUARTState, busdev.qdev, dev); StrongARMUARTState *s = STRONGARM_UART(dev);
s->utcr0 = UTCR0_DSS; /* 8 data, no parity */ s->utcr0 = UTCR0_DSS; /* 8 data, no parity */
s->brd = 23; /* 9600 */ s->brd = 23; /* 9600 */
@ -1324,7 +1329,7 @@ static void strongarm_uart_class_init(ObjectClass *klass, void *data)
} }
static const TypeInfo strongarm_uart_info = { static const TypeInfo strongarm_uart_info = {
.name = "strongarm-uart", .name = TYPE_STRONGARM_UART,
.parent = TYPE_SYS_BUS_DEVICE, .parent = TYPE_SYS_BUS_DEVICE,
.instance_size = sizeof(StrongARMUARTState), .instance_size = sizeof(StrongARMUARTState),
.class_init = strongarm_uart_class_init, .class_init = strongarm_uart_class_init,
@ -1619,7 +1624,7 @@ StrongARMState *sa1110_init(MemoryRegion *sysmem,
s->ppc = sysbus_create_varargs(TYPE_STRONGARM_PPC, 0x90060000, NULL); s->ppc = sysbus_create_varargs(TYPE_STRONGARM_PPC, 0x90060000, NULL);
for (i = 0; sa_serial[i].io_base; i++) { for (i = 0; sa_serial[i].io_base; i++) {
DeviceState *dev = qdev_create(NULL, "strongarm-uart"); DeviceState *dev = qdev_create(NULL, TYPE_STRONGARM_UART);
qdev_prop_set_chr(dev, "chardev", serial_hds[i]); qdev_prop_set_chr(dev, "chardev", serial_hds[i]);
qdev_init_nofail(dev); qdev_init_nofail(dev);
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0,