aboutsummaryrefslogtreecommitdiff
path: root/hw/char/serial.c
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2019-10-22 00:32:57 +0200
committerMarc-André Lureau <marcandre.lureau@redhat.com>2020-01-07 16:50:48 +0400
commitff22c588f474c6799015365d25548ab845a4f5cd (patch)
tree367dc18d036604443e92edebdd2cd50da34ee920 /hw/char/serial.c
parent4cc017e505df7e5344e4dfe7fc17711117c5f11f (diff)
serial: add "chardev" property
This is more QOM-friendly, callers may set/get the property themself. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'hw/char/serial.c')
-rw-r--r--hw/char/serial.c13
1 files 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);