qemu-devel
[Top][All Lists]
Advanced

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

[PULL 12/30] hw/char/sh_serial: Split off sh_serial_reset() from sh_seri


From: Philippe Mathieu-Daudé
Subject: [PULL 12/30] hw/char/sh_serial: Split off sh_serial_reset() from sh_serial_init()
Date: Sat, 30 Oct 2021 19:05:57 +0200

From: BALATON Zoltan <balaton@eik.bme.hu>

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: 
<ffb46f2814794c8dfc2c5a0cf83086a7bd754e10.1635541329.git.balaton@eik.bme.hu>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/char/sh_serial.c | 35 ++++++++++++++++++++---------------
 1 file changed, 20 insertions(+), 15 deletions(-)

diff --git a/hw/char/sh_serial.c b/hw/char/sh_serial.c
index 5ee93dc732a..80a548d19d9 100644
--- a/hw/char/sh_serial.c
+++ b/hw/char/sh_serial.c
@@ -381,6 +381,25 @@ static const MemoryRegionOps sh_serial_ops = {
     .endianness = DEVICE_NATIVE_ENDIAN,
 };
 
+static void sh_serial_reset(SHSerialState *s)
+{
+    s->flags = SH_SERIAL_FLAG_TEND | SH_SERIAL_FLAG_TDE;
+    s->rtrg = 1;
+
+    s->smr = 0;
+    s->brr = 0xff;
+    s->scr = 1 << 5; /* pretend that TX is enabled so early printk works */
+    s->sptr = 0;
+
+    if (s->feat & SH_SERIAL_FEAT_SCIF) {
+        s->fcr = 0;
+    } else {
+        s->dr = 0xff;
+    }
+
+    sh_serial_clear_fifo(s);
+}
+
 void sh_serial_init(MemoryRegion *sysmem,
                     hwaddr base, int feat,
                     uint32_t freq, Chardev *chr,
@@ -393,21 +412,7 @@ void sh_serial_init(MemoryRegion *sysmem,
     SHSerialState *s = g_malloc0(sizeof(*s));
 
     s->feat = feat;
-    s->flags = SH_SERIAL_FLAG_TEND | SH_SERIAL_FLAG_TDE;
-    s->rtrg = 1;
-
-    s->smr = 0;
-    s->brr = 0xff;
-    s->scr = 1 << 5; /* pretend that TX is enabled so early printk works */
-    s->sptr = 0;
-
-    if (feat & SH_SERIAL_FEAT_SCIF) {
-        s->fcr = 0;
-    } else {
-        s->dr = 0xff;
-    }
-
-    sh_serial_clear_fifo(s);
+    sh_serial_reset(s);
 
     memory_region_init_io(&s->iomem, NULL, &sh_serial_ops, s,
                           "serial", 0x100000000ULL);
-- 
2.31.1




reply via email to

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