diff mbox series

[RFC,06/12] core/console: Kill con_in

Message ID 20200519054633.113238-7-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_in variable is used to keep track of where the write pointer of
the skiboot log buffer is. The memcons.out_pos field tracks the same
information so we can remove con_in and use the internal field instead.

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

Patch

diff --git a/core/console.c b/core/console.c
index 8be7ee578b18..3ef360fe0c65 100644
--- a/core/console.c
+++ b/core/console.c
@@ -16,7 +16,6 @@ 
 #include <cpu.h>
 
 static char *con_buf = (char *)INMEM_CON_START;
-static size_t con_in;
 
 /*
  * Skiboot is both the producer and consumer of the memcons. On the consumer
@@ -110,7 +109,7 @@  static bool __flush_console(bool flush_to_drivers, bool need_unlock)
 	static bool in_flush, more_flush;
 
 	/* Is there anything to flush ? Bail out early if not */
-	if (con_in == con_out || !con_driver)
+	if (memcons.out_pos == con_out || !con_driver)
 		return false;
 
 	/*
@@ -149,7 +148,7 @@  static bool __flush_console(bool flush_to_drivers, bool need_unlock)
 	 *     con_out.
 	 */
 	if (!flush_to_drivers) {
-		con_out = con_in;
+		con_out = memcons.out_pos;
 		in_flush = false;
 		return false;
 	}
@@ -157,11 +156,11 @@  static bool __flush_console(bool flush_to_drivers, bool need_unlock)
 	do {
 		more_flush = false;
 
-		if (con_out > con_in) {
+		if (con_out > memcons.out_pos) {
 			req = INMEM_CON_OUT_LEN - con_out;
 			more_flush = true;
 		} else
-			req = con_in - con_out;
+			req = memcons.out_pos - con_out;
 
 		unlock(&con_lock);
 		len = con_driver->write(con_buf + con_out, req);
@@ -175,7 +174,7 @@  static bool __flush_console(bool flush_to_drivers, bool need_unlock)
 	} while(more_flush);
 
 	in_flush = false;
-	return con_out != con_in;
+	return con_out != memcons.out_pos;
 }
 
 bool flush_console(void)
@@ -195,9 +194,9 @@  static void inmem_write(char c)
 
 	if (!c)
 		return;
-	con_buf[con_in++] = c;
-	if (con_in >= INMEM_CON_OUT_LEN) {
-		con_in = 0;
+	memcons.obuf[memcons.out_pos++] = c;
+	if (memcons.out_pos >= INMEM_CON_OUT_LEN) {
+		memcons.out_pos = 0;
 		con_wrapped = true;
 	}
 
@@ -208,7 +207,7 @@  static void inmem_write(char c)
 	 * 8 bytes containing out_pos and in_prod, thus corrupting
 	 * out_pos
 	 */
-	opos = con_in;
+	opos = memcons.out_pos;
 	if (con_wrapped)
 		opos |= MEMCONS_OUT_POS_WRAP;
 	lwsync();