serial: replace serial_exit_core() with unrealize

Instead of calling serial_exit_core() directly, use the QDev unrealize
callback.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
This commit is contained in:
Marc-André Lureau 2019-10-22 01:14:43 +02:00
parent c9808d6028
commit b9975000a0
4 changed files with 6 additions and 4 deletions

View File

@ -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]);
}

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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"