qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v4 10/37] serial: realize the serial device


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH v4 10/37] serial: realize the serial device
Date: Wed, 20 Nov 2019 17:12:11 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.1

On 11/20/19 4:24 PM, Marc-André Lureau wrote:
Instead of calling serial_realize_core(), use the QDev realize
callback.

Signed-off-by: Marc-André Lureau <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 4a598ead21..1f3859eef1 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);
@@ -1011,6 +1012,7 @@ static void serial_class_init(ObjectClass *klass, void* data)
      DeviceClass *dc = DEVICE_CLASS(klass);
dc->user_creatable = false;
+    dc->realize = serial_realize;
      dc->vmsd = &vmstate_serial;
      dc->props = serial_properties;
  }
@@ -1074,8 +1076,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);

Reviewed-by: Philippe Mathieu-Daudé <address@hidden>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]