Message ID | 20191023173154.30051-13-marcandre.lureau@redhat.com |
---|---|
State | New |
Headers | show |
Series | Clean-ups: qom-ify serial and remove QDEV_PROP_PTR | expand |
On Wed, 23 Oct 2019 at 18:33, Marc-André Lureau <marcandre.lureau@redhat.com> wrote: > > 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> thanks -- PMM
On 10/23/19 7:31 PM, Marc-André Lureau wrote: > Instead of calling serial_exit_core() directly, use the QDev unrealize > callback. > > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> > --- > 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 60c1c948b8..a3200555aa 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 35a8552674..54bdd98325 100644 > --- a/hw/char/serial-pci.c > +++ b/hw/char/serial-pci.c > @@ -69,7 +69,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 bf34d9594e..667570e310 100644 > --- a/hw/char/serial.c > +++ b/hw/char/serial.c > @@ -951,8 +951,10 @@ static void serial_realize(DeviceState *dev, Error **errp) > qdev_set_legacy_instance_id(dev, s->instance_id, 2); > } > > -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) > DeviceClass *dc = DEVICE_CLASS(klass); > > 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 b445df5951..7cc6304f1d 100644 > --- a/include/hw/char/serial.h > +++ b/include/hw/char/serial.h > @@ -84,7 +84,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" > Nice. Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
diff --git a/hw/char/serial-pci-multi.c b/hw/char/serial-pci-multi.c index 60c1c948b8..a3200555aa 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 35a8552674..54bdd98325 100644 --- a/hw/char/serial-pci.c +++ b/hw/char/serial-pci.c @@ -69,7 +69,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 bf34d9594e..667570e310 100644 --- a/hw/char/serial.c +++ b/hw/char/serial.c @@ -951,8 +951,10 @@ static void serial_realize(DeviceState *dev, Error **errp) qdev_set_legacy_instance_id(dev, s->instance_id, 2); } -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) DeviceClass *dc = DEVICE_CLASS(klass); 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 b445df5951..7cc6304f1d 100644 --- a/include/hw/char/serial.h +++ b/include/hw/char/serial.h @@ -84,7 +84,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"
Instead of calling serial_exit_core() directly, use the QDev unrealize callback. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> --- 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(-)