Skip to contentSkip to conversation

x86, setup: move out serial_putchar out of putchar

PATCH New Yinghai Lu 1 participant 1 message Aug 29, 2010 x86

lore
Share & tools
lore

Yinghai Lu

author
#0 lore raw

PATCH 1/1 x86, setup: move out serial_putchar out of putchar

let puts to call serial_putchar directly.

So only need to check early_serial_base per string.

---
 arch/x86/boot/tty.c |   14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
arch/x86/boot/tty.c +10 -4
Index: linux-2.6/arch/x86/boot/tty.c
===================================================================
@@ -52,16 +52,22 @@ static void __attribute__((section(".ini
 void __attribute__((section(".inittext"))) putchar(int ch)
 {
 	if (ch == '\n')
-		putchar('\r');	/* \n -> \r\n */
+		bios_putchar('\r');	/* \n -> \r\n */
 
 	bios_putchar(ch);
-
-	if (early_serial_base != 0)
-		serial_putchar(ch);
 }
 
 void __attribute__((section(".inittext"))) puts(const char *str)
 {
+	if (early_serial_base) {
+		const char *s = str;
+		while (*s) {
+			if (*s == '\n')
+				serial_putchar('\r');
+			serial_putchar(*s++);
+		}
+	}
+
 	while (*str)
 		putchar(*str++);
 }