From b9975000a008c5b0801e3d24ed113a1bd2767ed5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Tue, 22 Oct 2019 01:14:43 +0200 Subject: [PATCH] serial: replace serial_exit_core() with unrealize MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of calling serial_exit_core() directly, use the QDev unrealize callback. Signed-off-by: Marc-André Lureau Reviewed-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé --- hw/char/serial-pci-multi.c | 2 +- hw/char/serial-pci.c | 2 +- hw/char/serial.c | 5 ++++- include/hw/char/serial.h | 1 - 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/hw/char/serial-pci-multi.c b/hw/char/serial-pci-multi.c index 0e1fdb75d2..e343a1235c 100644 --- a/hw/char/serial-pci-multi.c +++ b/hw/char/serial-pci-multi.c @@ -56,7 +56,7 @@ static void multi_serial_pci_exit(PCIDevice *dev) for (i = 0; i < pci->ports; i++) { s = pci->state + i; - serial_exit_core(s); + object_property_set_bool(OBJECT(s), false, "realized", NULL); memory_region_del_subregion(&pci->iobar, &s->io); g_free(pci->name[i]); } diff --git a/hw/char/serial-pci.c b/hw/char/serial-pci.c index 4b6a217365..b6a73c65a9 100644 --- a/hw/char/serial-pci.c +++ b/hw/char/serial-pci.c @@ -68,7 +68,7 @@ static void serial_pci_exit(PCIDevice *dev) PCISerialState *pci = DO_UPCAST(PCISerialState, dev, dev); SerialState *s = &pci->state; - serial_exit_core(s); + object_property_set_bool(OBJECT(s), false, "realized", NULL); qemu_free_irq(s->irq); } diff --git a/hw/char/serial.c b/hw/char/serial.c index 8328cc62c3..ec388f3876 100644 --- a/hw/char/serial.c +++ b/hw/char/serial.c @@ -950,8 +950,10 @@ static void serial_realize(DeviceState *dev, Error **errp) serial_reset(s); } -void serial_exit_core(SerialState *s) +static void serial_unrealize(DeviceState *dev, Error **errp) { + SerialState *s = SERIAL(dev); + qemu_chr_fe_deinit(&s->chr, false); timer_del(s->modem_status_poll); @@ -1014,6 +1016,7 @@ static void serial_class_init(ObjectClass *klass, void* data) /* internal device for serialio/serialmm, not user-creatable */ dc->user_creatable = false; dc->realize = serial_realize; + dc->unrealize = serial_unrealize; dc->vmsd = &vmstate_serial; dc->props = serial_properties; } diff --git a/include/hw/char/serial.h b/include/hw/char/serial.h index 571aab97c8..548944b06a 100644 --- a/include/hw/char/serial.h +++ b/include/hw/char/serial.h @@ -83,7 +83,6 @@ typedef struct SerialState { extern const VMStateDescription vmstate_serial; extern const MemoryRegionOps serial_io_ops; -void serial_exit_core(SerialState *s); void serial_set_frequency(SerialState *s, uint32_t frequency); #define TYPE_SERIAL "serial"