All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: Paolo Bonzini <pbonzini@redhat.com>,
	Peter Maydell <peter.maydell@linaro.org>,
	Peter Chubb <peter.chubb@nicta.com.au>
Cc: "Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	qemu-devel@nongnu.org, qemu-arm@nongnu.org
Subject: [Qemu-devel] [PATCH 3/7] hw/arm/fsl_imx*: use serial_chr_nonnull()
Date: Thu, 31 Aug 2017 00:53:02 -0300	[thread overview]
Message-ID: <20170831035306.29170-4-f4bug@amsat.org> (raw)
In-Reply-To: <20170831035306.29170-1-f4bug@amsat.org>

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(-)

diff --git a/include/hw/char/imx_serial.h b/include/hw/char/imx_serial.h
index baeec3183f..55139dc6ec 100644
--- a/include/hw/char/imx_serial.h
+++ b/include/hw/char/imx_serial.h
@@ -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)
diff --git a/hw/arm/fsl-imx25.c b/hw/arm/fsl-imx25.c
index 3b97eceb3c..425a9edc36 100644
--- a/hw/arm/fsl-imx25.c
+++ b/hw/arm/fsl-imx25.c
@@ -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);
         }
 
diff --git a/hw/arm/fsl-imx31.c b/hw/arm/fsl-imx31.c
index 0f2ebe8161..8d4535a536 100644
--- a/hw/arm/fsl-imx31.c
+++ b/hw/arm/fsl-imx31.c
@@ -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);
         }
 
diff --git a/hw/arm/fsl-imx6.c b/hw/arm/fsl-imx6.c
index 26fd214004..7bc1aa1fbe 100644
--- a/hw/arm/fsl-imx6.c
+++ b/hw/arm/fsl-imx6.c
@@ -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);
         }
 
-- 
2.14.1

  parent reply	other threads:[~2017-08-31  3:53 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-31  3:52 [Qemu-devel] [PATCH 0/7] serial: add serial_chr_nonnull() Philippe Mathieu-Daudé
2017-08-31  3:53 ` [Qemu-devel] [PATCH 1/7] serial: add serial_chr_nonnull() to use the null backend when none provided Philippe Mathieu-Daudé
2017-08-31  5:19   ` Thomas Huth
2017-08-31  9:36     ` Marc-André Lureau
2017-08-31  9:43       ` Thomas Huth
2017-08-31 15:24         ` Philippe Mathieu-Daudé
2017-09-01  9:12           ` Markus Armbruster
2017-08-31 15:20     ` Philippe Mathieu-Daudé
2017-08-31 15:23       ` Thomas Huth
2017-08-31 10:28   ` Peter Maydell
2017-08-31 15:17     ` Philippe Mathieu-Daudé
2017-08-31  3:53 ` [Qemu-devel] [PATCH 2/7] serial: use serial_chr_nonnull() in serial_mm_init() Philippe Mathieu-Daudé
2017-08-31  3:53 ` Philippe Mathieu-Daudé [this message]
2017-08-31  3:53 ` [Qemu-devel] [PATCH 4/7] hw/mips/malta: use serial_chr_nonnull() Philippe Mathieu-Daudé
2017-08-31  3:53 ` [Qemu-devel] [PATCH 5/7] hw/char/exynos4210_uart: " Philippe Mathieu-Daudé
2017-08-31  3:53 ` [Qemu-devel] [PATCH 6/7] hw/char/omap_uart: serial_mm_init() already check for null chr Philippe Mathieu-Daudé
2017-08-31  3:53 ` [Qemu-devel] [PATCH 7/7] hw/xtensa: " Philippe Mathieu-Daudé
2017-09-05 14:56 ` [Qemu-devel] [PATCH 0/7] serial: add serial_chr_nonnull() Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170831035306.29170-4-f4bug@amsat.org \
    --to=f4bug@amsat.org \
    --cc=pbonzini@redhat.com \
    --cc=peter.chubb@nicta.com.au \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.