@@ -20,6 +20,7 @@
#include "hw/sysbus.h"
#include "chardev/char-fe.h"
+#include "hw/char/serial.h"
#define TYPE_IMX_SERIAL "imx.serial"
#define IMX_SERIAL(obj) OBJECT_CHECK(IMXSerialState, (obj), TYPE_IMX_SERIAL)
@@ -120,14 +120,7 @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp)
if (i < MAX_SERIAL_PORTS) {
Chardev *chr;
- chr = serial_hds[i];
-
- if (!chr) {
- char label[20];
- snprintf(label, sizeof(label), "imx31.uart%d", i);
- chr = qemu_chr_new(label, "null");
- }
-
+ chr = serial_chr_nonnull(serial_hds[i]);
qdev_prop_set_chr(DEVICE(&s->uart[i]), "chardev", chr);
}
@@ -109,14 +109,7 @@ static void fsl_imx31_realize(DeviceState *dev, Error **errp)
if (i < MAX_SERIAL_PORTS) {
Chardev *chr;
- chr = serial_hds[i];
-
- if (!chr) {
- char label[20];
- snprintf(label, sizeof(label), "imx31.uart%d", i);
- chr = qemu_chr_new(label, "null");
- }
-
+ chr = serial_chr_nonnull(serial_hds[i]);
qdev_prop_set_chr(DEVICE(&s->uart[i]), "chardev", chr);
}
@@ -189,15 +189,7 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)
if (i < MAX_SERIAL_PORTS) {
Chardev *chr;
- chr = serial_hds[i];
-
- if (!chr) {
- char *label = g_strdup_printf("imx6.uart%d", i + 1);
- chr = qemu_chr_new(label, "null");
- g_free(label);
- serial_hds[i] = chr;
- }
-
+ chr = serial_chr_nonnull(serial_hds[i]);
qdev_prop_set_chr(DEVICE(&s->uart[i]), "chardev", chr);
}
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> --- include/hw/char/imx_serial.h | 1 + hw/arm/fsl-imx25.c | 9 +-------- hw/arm/fsl-imx31.c | 9 +-------- hw/arm/fsl-imx6.c | 10 +--------- 4 files changed, 4 insertions(+), 25 deletions(-)