diff mbox series

[RFC,03/12] core/console: Move con_out wrap marking

Message ID 20200519054633.113238-4-oohall@gmail.com
State RFC
Headers show
Series [RFC,01/12] platform/mambo: Add a mambo OPAL console driver | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success Successfully applied on branch master (0f1937ef40fca0c3212a9dff1010b832a24fb063)
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot success Test snowpatch/job/snowpatch-skiboot on branch master
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot-dco success Signed-off-by present

Commit Message

Oliver O'Halloran May 19, 2020, 5:46 a.m. UTC
The con_out global tracks how much of the skiboot log buffer has been
written out to the driver. We'd like to re-use inmem_write() so that we
can have multiple memcons instances so move the con_out tracking into
write_char() which is used to write a single character into the skiboot
log buffer.

Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
---
 core/console.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/core/console.c b/core/console.c
index 42328dbe2d2e..8724c71113a6 100644
--- a/core/console.c
+++ b/core/console.c
@@ -198,10 +198,6 @@  static void inmem_write(char c)
 		opos |= MEMCONS_OUT_POS_WRAP;
 	lwsync();
 	memcons.out_pos = cpu_to_be32(opos);
-
-	/* If head reaches tail, push tail around & drop chars */
-	if (con_in == con_out)
-		con_out = (con_in + 1) % INMEM_CON_OUT_LEN;
 }
 
 static size_t inmem_read(char *buf, size_t req)
@@ -221,10 +217,11 @@  static size_t inmem_read(char *buf, size_t req)
 
 static void write_char(char c)
 {
-#ifdef MAMBO_DEBUG_CONSOLE
-	mambo_console_write(&c, 1);
-#endif
 	inmem_write(c);
+
+	/* If head reaches tail, push tail around & drop chars */
+	if (con_out == memcons.out_pos)
+		con_out = (memcons.out_pos + 1) % memcons.obuf_size;
 }
 
 ssize_t console_write(bool flush_to_drivers, const void *buf, size_t count)