Instead of calling serial_realize_core(), use the QDev realize callback. Move qdev_set_legacy_instance_id() there.
Signed-off-by: Marc-André Lureau <marcandre.lur...@redhat.com> --- hw/char/serial-isa.c | 2 +- hw/char/serial-pci-multi.c | 2 +- hw/char/serial-pci.c | 2 +- hw/char/serial.c | 12 ++++++------ include/hw/char/serial.h | 1 - 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/hw/char/serial-isa.c b/hw/char/serial-isa.c index 9a5928b3ee..33e093f1e6 100644 --- a/hw/char/serial-isa.c +++ b/hw/char/serial-isa.c @@ -75,7 +75,7 @@ static void serial_isa_realizefn(DeviceState *dev, Error **errp) s->baudbase = 115200; isa_init_irq(isadev, &s->irq, isa->isairq); - serial_realize_core(s, errp); + object_property_set_bool(OBJECT(s), true, "realized", errp); qdev_set_legacy_instance_id(dev, isa->iobase, 3); memory_region_init_io(&s->io, OBJECT(isa), &serial_io_ops, s, "serial", 8); diff --git a/hw/char/serial-pci-multi.c b/hw/char/serial-pci-multi.c index 3485bdad87..60c1c948b8 100644 --- a/hw/char/serial-pci-multi.c +++ b/hw/char/serial-pci-multi.c @@ -108,7 +108,7 @@ static void multi_serial_pci_realize(PCIDevice *dev, Error **errp) for (i = 0; i < nr_ports; i++) { s = pci->state + i; s->baudbase = 115200; - serial_realize_core(s, &err); + object_property_set_bool(OBJECT(s), true, "realized", &err); if (err != NULL) { error_propagate(errp, err); multi_serial_pci_exit(dev); diff --git a/hw/char/serial-pci.c b/hw/char/serial-pci.c index a33264a1fb..35a8552674 100644 --- a/hw/char/serial-pci.c +++ b/hw/char/serial-pci.c @@ -50,7 +50,7 @@ static void serial_pci_realize(PCIDevice *dev, Error **errp) Error *err = NULL; s->baudbase = 115200; - serial_realize_core(s, &err); + object_property_set_bool(OBJECT(s), true, "realized", &err); if (err != NULL) { error_propagate(errp, err); return; diff --git a/hw/char/serial.c b/hw/char/serial.c index 4748a2b023..1500216c69 100644 --- a/hw/char/serial.c +++ b/hw/char/serial.c @@ -934,8 +934,10 @@ static int serial_be_change(void *opaque) return 0; } -void serial_realize_core(SerialState *s, Error **errp) +static void serial_realize(DeviceState *dev, Error **errp) { + SerialState *s = SERIAL(dev); + s->modem_status_poll = timer_new_ns(QEMU_CLOCK_VIRTUAL, (QEMUTimerCB *) serial_update_msl, s); s->fifo_timeout_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, (QEMUTimerCB *) fifo_timeout_int, s); @@ -946,6 +948,8 @@ void serial_realize_core(SerialState *s, Error **errp) fifo8_create(&s->recv_fifo, UART_FIFO_LENGTH); fifo8_create(&s->xmit_fifo, UART_FIFO_LENGTH); serial_reset(s); + + qdev_set_legacy_instance_id(dev, s->base, 2); } void serial_exit_core(SerialState *s) @@ -991,8 +995,6 @@ SerialState *serial_init(int base, qemu_irq irq, int baudbase, qdev_prop_set_uint32(dev, "baudbase", baudbase); qdev_prop_set_chr(dev, "chardev", chr); qdev_prop_set_uint64(dev, "base", base); - serial_realize_core(s, &error_fatal); - qdev_set_legacy_instance_id(dev, base, 2); qdev_init_nofail(dev); memory_region_init_io(&s->io, NULL, &serial_io_ops, s, "serial", 8); @@ -1012,6 +1014,7 @@ static void serial_class_init(ObjectClass *klass, void* data) { DeviceClass *dc = DEVICE_CLASS(klass); + dc->realize = serial_realize; dc->user_creatable = false; dc->vmsd = &vmstate_serial; dc->props = serial_properties; @@ -1086,9 +1089,6 @@ SerialState *serial_mm_init(MemoryRegion *address_space, qdev_prop_set_chr(dev, "chardev", chr); qdev_prop_set_uint8(dev, "regshift", regshift); qdev_prop_set_uint64(dev, "base", base); - - serial_realize_core(s, &error_fatal); - qdev_set_legacy_instance_id(DEVICE(s), base, 2); qdev_init_nofail(dev); memory_region_init_io(&s->io, NULL, &serial_mm_ops[end], s, diff --git a/include/hw/char/serial.h b/include/hw/char/serial.h index 6e9c9768ed..28bce0a791 100644 --- a/include/hw/char/serial.h +++ b/include/hw/char/serial.h @@ -89,7 +89,6 @@ typedef struct SerialMMState { extern const VMStateDescription vmstate_serial; extern const MemoryRegionOps serial_io_ops; -void serial_realize_core(SerialState *s, Error **errp); void serial_exit_core(SerialState *s); void serial_set_frequency(SerialState *s, uint32_t frequency); -- 2.23.0.606.g08da6496b6