From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: qemu-devel@nongnu.org
Cc: "Yoshinori Sato" <ysato@users.sourceforge.jp>,
"Magnus Damm" <magnus.damm@gmail.com>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>
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 [thread overview]
Message-ID: <20211030170615.2636436-13-f4bug@amsat.org> (raw)
In-Reply-To: <20211030170615.2636436-1-f4bug@amsat.org>
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
next prev parent reply other threads:[~2021-10-30 17:12 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-30 17:05 [PULL 00/30] Renesas SH-4 patches for 2021-10-30 Philippe Mathieu-Daudé
2021-10-30 17:05 ` [PULL 01/30] hw/sh4: Coding style: Remove tabs Philippe Mathieu-Daudé
2021-10-30 17:05 ` [PULL 02/30] hw/sh4: Coding style: Fix multi-line comments Philippe Mathieu-Daudé
2021-10-30 17:05 ` [PULL 03/30] hw/sh4: Coding style: White space fixes Philippe Mathieu-Daudé
2021-10-30 17:05 ` [PULL 04/30] hw/sh4: Coding style: Add missing braces Philippe Mathieu-Daudé
2021-10-30 17:05 ` [PULL 05/30] hw/sh4: Coding style: Remove unnecessary casts Philippe Mathieu-Daudé
2021-10-30 17:05 ` [PULL 06/30] hw/sh4: Fix typos in a comment Philippe Mathieu-Daudé
2021-10-30 17:05 ` [PULL 07/30] hw/sh4: Change debug printfs to traces Philippe Mathieu-Daudé
2021-10-30 17:05 ` [PULL 08/30] hw/sh4/r2d: Use error_report instead of fprintf to stderr Philippe Mathieu-Daudé
2021-10-30 17:05 ` [PULL 09/30] hw/char/sh_serial: Do not abort on invalid access Philippe Mathieu-Daudé
2021-10-30 17:05 ` [PULL 10/30] hw/char/sh_serial: Rename type sh_serial_state to SHSerialState Philippe Mathieu-Daudé
2021-10-30 17:05 ` [PULL 11/30] hw/char/sh_serial: Embed QEMUTimer in state struct Philippe Mathieu-Daudé
2021-10-30 17:05 ` Philippe Mathieu-Daudé [this message]
2021-10-30 17:05 ` [PULL 13/30] hw/char/sh_serial: QOM-ify Philippe Mathieu-Daudé
2021-10-30 17:05 ` [PULL 14/30] hw/char/sh_serial: Add device id to trace output Philippe Mathieu-Daudé
2021-10-30 17:06 ` [PULL 15/30] hw/intc/sh_intc: Use existing macro instead of local one Philippe Mathieu-Daudé
2021-10-30 17:06 ` [PULL 16/30] hw/intc/sh_intc: Turn some defines into an enum Philippe Mathieu-Daudé
2021-10-30 17:06 ` [PULL 17/30] hw/intc/sh_intc: Rename iomem region Philippe Mathieu-Daudé
2021-10-30 17:06 ` [PULL 18/30] hw/intc/sh_intc: Drop another useless macro Philippe Mathieu-Daudé
2021-10-30 17:06 ` [PULL 19/30] hw/intc/sh_intc: Move sh_intc_register() closer to its only user Philippe Mathieu-Daudé
2021-10-30 17:06 ` [PULL 20/30] hw/intc/sh_intc: Remove excessive parenthesis Philippe Mathieu-Daudé
2021-10-30 17:06 ` [PULL 21/30] hw/intc/sh_intc: Use array index instead of pointer arithmetics Philippe Mathieu-Daudé
2021-10-30 17:06 ` [PULL 22/30] hw/intc/sh_intc: Inline and drop sh_intc_source() function Philippe Mathieu-Daudé
2021-10-30 17:06 ` [PULL 23/30] hw/intc/sh_intc: Replace abort() with g_assert_not_reached() Philippe Mathieu-Daudé
2021-10-30 17:06 ` [PULL 24/30] hw/intc/sh_intc: Avoid using continue in loops Philippe Mathieu-Daudé
2021-10-30 17:06 ` [PULL 25/30] hw/intc/sh_intc: Simplify allocating sources array Philippe Mathieu-Daudé
2021-10-30 17:06 ` [PULL 26/30] hw/intc/sh_intc: Remove unneeded local variable initialisers Philippe Mathieu-Daudé
2021-10-30 17:06 ` [PULL 27/30] hw/timer/sh_timer: Rename sh_timer_state to SHTimerState Philippe Mathieu-Daudé
2021-10-30 17:06 ` [PULL 28/30] hw/timer/sh_timer: Do not wrap lines that are not too long Philippe Mathieu-Daudé
2021-10-30 17:06 ` [PULL 29/30] hw/timer/sh_timer: Fix timer memory region size Philippe Mathieu-Daudé
2021-10-30 17:06 ` [PULL 30/30] hw/timer/sh_timer: Remove use of hw_error Philippe Mathieu-Daudé
2021-10-30 20:13 ` [PULL 00/30] Renesas SH-4 patches for 2021-10-30 Richard Henderson
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=20211030170615.2636436-13-f4bug@amsat.org \
--to=f4bug@amsat.org \
--cc=magnus.damm@gmail.com \
--cc=marcandre.lureau@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=ysato@users.sourceforge.jp \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).