summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc-André Lureau2019-10-22 01:02:50 +0200
committerMarc-André Lureau2020-01-07 13:50:48 +0100
commitc9808d602813bce4fada7bf9ecc463aa779b73f7 (patch)
treeaf4b95f690cbcd97139756bcf6e4146a8d7d24da
parentserial: add "baudbase" property (diff)
downloadqemu-c9808d602813bce4fada7bf9ecc463aa779b73f7.tar.gz
qemu-c9808d602813bce4fada7bf9ecc463aa779b73f7.tar.xz
qemu-c9808d602813bce4fada7bf9ecc463aa779b73f7.zip
serial: realize the serial device
Instead of calling serial_realize_core(), use the QDev realize callback. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
-rw-r--r--hw/char/serial-isa.c2
-rw-r--r--hw/char/serial-pci-multi.c2
-rw-r--r--hw/char/serial-pci.c2
-rw-r--r--hw/char/serial.c8
-rw-r--r--include/hw/char/serial.h1
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);