[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v5 10/37] serial: realize the serial device
From: |
Marc-André Lureau |
Subject: |
[PATCH v5 10/37] serial: realize the serial device |
Date: |
Fri, 20 Dec 2019 17:45:34 +0400 |
Instead of calling serial_realize_core(), use the QDev realize
callback.
Signed-off-by: Marc-André Lureau <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
---
hw/char/serial-isa.c | 2 +-
hw/char/serial-pci-multi.c | 2 +-
hw/char/serial-pci.c | 2 +-
hw/char/serial.c | 8 ++++----
include/hw/char/serial.h | 1 -
5 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/hw/char/serial-isa.c b/hw/char/serial-isa.c
index 2a4c8de1bf..db8644551e 100644
--- a/hw/char/serial-isa.c
+++ b/hw/char/serial-isa.c
@@ -74,7 +74,7 @@ static void serial_isa_realizefn(DeviceState *dev, Error
**errp)
index++;
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 4891f32230..0e1fdb75d2 100644
--- a/hw/char/serial-pci-multi.c
+++ b/hw/char/serial-pci-multi.c
@@ -106,7 +106,7 @@ static void multi_serial_pci_realize(PCIDevice *dev, Error
**errp)
for (i = 0; i < nports; i++) {
s = pci->state + i;
- 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 db2c17aafd..4b6a217365 100644
--- a/hw/char/serial-pci.c
+++ b/hw/char/serial-pci.c
@@ -49,7 +49,7 @@ static void serial_pci_realize(PCIDevice *dev, Error **errp)
SerialState *s = &pci->state;
Error *err = NULL;
- 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 a4f0566865..8328cc62c3 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);
@@ -990,7 +992,6 @@ SerialState *serial_init(int base, qemu_irq irq, int
baudbase,
s->irq = irq;
qdev_prop_set_uint32(dev, "baudbase", baudbase);
qdev_prop_set_chr(dev, "chardev", chr);
- serial_realize_core(s, &error_fatal);
qdev_set_legacy_instance_id(dev, base, 2);
qdev_init_nofail(dev);
@@ -1012,6 +1013,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->vmsd = &vmstate_serial;
dc->props = serial_properties;
}
@@ -1075,8 +1077,6 @@ SerialState *serial_mm_init(MemoryRegion *address_space,
s->irq = irq;
qdev_prop_set_uint32(dev, "baudbase", baudbase);
qdev_prop_set_chr(dev, "chardev", chr);
-
- serial_realize_core(s, &error_fatal);
qdev_set_legacy_instance_id(dev, base, 2);
qdev_init_nofail(dev);
diff --git a/include/hw/char/serial.h b/include/hw/char/serial.h
index 3dc618598e..571aab97c8 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_realize_core(SerialState *s, Error **errp);
void serial_exit_core(SerialState *s);
void serial_set_frequency(SerialState *s, uint32_t frequency);
--
2.24.0.308.g228f53135a
- [PATCH v5 00/37] Clean-ups: qom-ify serial and remove QDEV_PROP_PTR, Marc-André Lureau, 2019/12/20
- [PATCH v5 01/37] hw/display/sm501: Always map the UART0, Marc-André Lureau, 2019/12/20
- [PATCH v5 02/37] sysbus: remove unused sysbus_try_create*, Marc-André Lureau, 2019/12/20
- [PATCH v5 03/37] sysbus: remove outdated comment, Marc-André Lureau, 2019/12/20
- [PATCH v5 04/37] chardev: generate an internal id when none given, Marc-André Lureau, 2019/12/20
- [PATCH v5 05/37] serial-pci-multi: factor out multi_serial_get_port_count(), Marc-André Lureau, 2019/12/20
- [PATCH v5 06/37] serial: initial qom-ification, Marc-André Lureau, 2019/12/20
- [PATCH v5 07/37] serial: register vmsd with DeviceClass, Marc-André Lureau, 2019/12/20
- [PATCH v5 08/37] serial: add "chardev" property, Marc-André Lureau, 2019/12/20
- [PATCH v5 09/37] serial: add "baudbase" property, Marc-André Lureau, 2019/12/20
- [PATCH v5 10/37] serial: realize the serial device,
Marc-André Lureau <=
- [PATCH v5 11/37] serial: replace serial_exit_core() with unrealize, Marc-André Lureau, 2019/12/20
- [PATCH v5 12/37] serial: start making SerialMM a sysbus device, Marc-André Lureau, 2019/12/20
- [PATCH v5 14/37] serial-mm: add endianness property, Marc-André Lureau, 2019/12/20
- [PATCH v5 15/37] serial-mm: use sysbus facilities, Marc-André Lureau, 2019/12/20
- [PATCH v5 16/37] serial: make SerialIO a sysbus device, Marc-André Lureau, 2019/12/20
- [PATCH v5 17/37] mips: inline serial_init(), Marc-André Lureau, 2019/12/20
- [PATCH v5 13/37] serial-mm: add "regshift" property, Marc-André Lureau, 2019/12/20
- [PATCH v5 18/37] mips: baudbase is 115200 by default, Marc-André Lureau, 2019/12/20
- [PATCH v5 19/37] mips: use sysbus_add_io(), Marc-André Lureau, 2019/12/20
- [PATCH v5 20/37] mips: use sysbus_mmio_get_region() instead of internal fields, Marc-André Lureau, 2019/12/20