[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 08/37] serial: add "chardev" property
From: |
Marc-André Lureau |
Subject: |
[PULL 08/37] serial: add "chardev" property |
Date: |
Tue, 7 Jan 2020 19:04:13 +0400 |
This is more QOM-friendly, callers may set/get the property themself.
Signed-off-by: Marc-André Lureau <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Reviewed-by: Peter Maydell <address@hidden>
---
hw/char/serial.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/hw/char/serial.c b/hw/char/serial.c
index e926845843..1746dbc1c4 100644
--- a/hw/char/serial.c
+++ b/hw/char/serial.c
@@ -34,6 +34,7 @@
#include "sysemu/runstate.h"
#include "qemu/error-report.h"
#include "trace.h"
+#include "hw/qdev-properties.h"
//#define DEBUG_SERIAL
@@ -988,7 +989,7 @@ SerialState *serial_init(int base, qemu_irq irq, int
baudbase,
s->irq = irq;
s->baudbase = baudbase;
- qemu_chr_fe_init(&s->chr, chr, &error_abort);
+ 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);
@@ -999,13 +1000,19 @@ SerialState *serial_init(int base, qemu_irq irq, int
baudbase,
return s;
}
-static void serial_class_init(ObjectClass *klass, void *data)
+static Property serial_properties[] = {
+ DEFINE_PROP_CHR("chardev", SerialState, chr),
+ DEFINE_PROP_END_OF_LIST(),
+};
+
+static void serial_class_init(ObjectClass *klass, void* data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
/* internal device for serialio/serialmm, not user-creatable */
dc->user_creatable = false;
dc->vmsd = &vmstate_serial;
+ dc->props = serial_properties;
}
static const TypeInfo serial_info = {
@@ -1066,7 +1073,7 @@ SerialState *serial_mm_init(MemoryRegion *address_space,
s->it_shift = it_shift;
s->irq = irq;
s->baudbase = baudbase;
- qemu_chr_fe_init(&s->chr, chr, &error_abort);
+ qdev_prop_set_chr(dev, "chardev", chr);
serial_realize_core(s, &error_fatal);
qdev_set_legacy_instance_id(dev, base, 2);
--
2.25.0.rc1.20.g2443f3f80d
- [PULL 00/37] qom-ify serial and remove QDEV_PROP_PTR, Marc-André Lureau, 2020/01/07
- [PULL 01/37] hw/display/sm501: Always map the UART0, Marc-André Lureau, 2020/01/07
- [PULL 02/37] sysbus: remove unused sysbus_try_create*, Marc-André Lureau, 2020/01/07
- [PULL 03/37] sysbus: remove outdated comment, Marc-André Lureau, 2020/01/07
- [PULL 04/37] chardev: generate an internal id when none given, Marc-André Lureau, 2020/01/07
- [PULL 05/37] serial-pci-multi: factor out multi_serial_get_port_count(), Marc-André Lureau, 2020/01/07
- [PULL 06/37] serial: initial qom-ification, Marc-André Lureau, 2020/01/07
- [PULL 07/37] serial: register vmsd with DeviceClass, Marc-André Lureau, 2020/01/07
- [PULL 08/37] serial: add "chardev" property,
Marc-André Lureau <=
- [PULL 09/37] serial: add "baudbase" property, Marc-André Lureau, 2020/01/07
- [PULL 10/37] serial: realize the serial device, Marc-André Lureau, 2020/01/07
- [PULL 11/37] serial: replace serial_exit_core() with unrealize, Marc-André Lureau, 2020/01/07
- [PULL 12/37] serial: start making SerialMM a sysbus device, Marc-André Lureau, 2020/01/07
- [PULL 13/37] serial-mm: add "regshift" property, Marc-André Lureau, 2020/01/07
- [PULL 14/37] serial-mm: add endianness property, Marc-André Lureau, 2020/01/07
- [PULL 15/37] serial-mm: use sysbus facilities, Marc-André Lureau, 2020/01/07
- [PULL 17/37] mips: inline serial_init(), Marc-André Lureau, 2020/01/07
- [PULL 16/37] serial: make SerialIO a sysbus device, Marc-André Lureau, 2020/01/07
- [PULL 18/37] mips: baudbase is 115200 by default, Marc-André Lureau, 2020/01/07