hw/arm/bcm2835: Use object_initialize() on PL011State

To be coherent with the other peripherals contained in the
BCM2835PeripheralState structure, directly allocate the PL011State
(instead of using the pl011 uart as a pointer to a SysBusDevice).

Initialize the PL011State with object_initialize() instead of
object_new().

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20190507163416.24647-6-philmd@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
This commit is contained in:
Philippe Mathieu-Daudé 2019-05-07 18:34:05 +02:00 committed by Eduardo Habkost
parent 0a21950e43
commit 948770b0a7
2 changed files with 8 additions and 8 deletions

View File

@ -46,9 +46,9 @@ static void bcm2835_peripherals_init(Object *obj)
qdev_set_parent_bus(DEVICE(&s->ic), sysbus_get_default()); qdev_set_parent_bus(DEVICE(&s->ic), sysbus_get_default());
/* UART0 */ /* UART0 */
s->uart0 = SYS_BUS_DEVICE(object_new(TYPE_PL011)); object_initialize(&s->uart0, sizeof(s->uart0), TYPE_PL011);
object_property_add_child(obj, "uart0", OBJECT(s->uart0), NULL); object_property_add_child(obj, "uart0", OBJECT(&s->uart0), NULL);
qdev_set_parent_bus(DEVICE(s->uart0), sysbus_get_default()); qdev_set_parent_bus(DEVICE(&s->uart0), sysbus_get_default());
/* AUX / UART1 */ /* AUX / UART1 */
object_initialize(&s->aux, sizeof(s->aux), TYPE_BCM2835_AUX); object_initialize(&s->aux, sizeof(s->aux), TYPE_BCM2835_AUX);
@ -166,16 +166,16 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
sysbus_pass_irq(SYS_BUS_DEVICE(s), SYS_BUS_DEVICE(&s->ic)); sysbus_pass_irq(SYS_BUS_DEVICE(s), SYS_BUS_DEVICE(&s->ic));
/* UART0 */ /* UART0 */
qdev_prop_set_chr(DEVICE(s->uart0), "chardev", serial_hd(0)); qdev_prop_set_chr(DEVICE(&s->uart0), "chardev", serial_hd(0));
object_property_set_bool(OBJECT(s->uart0), true, "realized", &err); object_property_set_bool(OBJECT(&s->uart0), true, "realized", &err);
if (err) { if (err) {
error_propagate(errp, err); error_propagate(errp, err);
return; return;
} }
memory_region_add_subregion(&s->peri_mr, UART0_OFFSET, memory_region_add_subregion(&s->peri_mr, UART0_OFFSET,
sysbus_mmio_get_region(s->uart0, 0)); sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->uart0), 0));
sysbus_connect_irq(s->uart0, 0, sysbus_connect_irq(SYS_BUS_DEVICE(&s->uart0), 0,
qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_GPU_IRQ, qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_GPU_IRQ,
INTERRUPT_UART)); INTERRUPT_UART));
/* AUX / UART1 */ /* AUX / UART1 */

View File

@ -38,7 +38,7 @@ typedef struct BCM2835PeripheralState {
MemoryRegion ram_alias[4]; MemoryRegion ram_alias[4];
qemu_irq irq, fiq; qemu_irq irq, fiq;
SysBusDevice *uart0; PL011State uart0;
BCM2835AuxState aux; BCM2835AuxState aux;
BCM2835FBState fb; BCM2835FBState fb;
BCM2835DMAState dma; BCM2835DMAState dma;