[PATCH 13/14] hvc_console: Separate the NUL character filtering from get_hvc_chars

Anton Blanchard anton at samba.org
Thu Jul 7 02:02:38 EST 2005


From: Milton Miller <miltonm at bga.com>

Separate the NUL character filtering from get_hvc_chars.

Signed-off-by: Milton Miller <miltonm at bga.com>
Signed-off-by: Anton Blanchard <anton at samba.org>

diff -puN arch/ppc64/kernel/hvconsole.c~hvc-console-nul-filter arch/ppc64/kernel/hvconsole.c
--- gr_work_small/arch/ppc64/kernel/hvconsole.c~hvc-console-nul-filter	2005-05-31 22:06:09.000000000 -0500
+++ gr_work_small-miltonm/arch/ppc64/kernel/hvconsole.c	2005-06-01 19:58:25.373370091 -0500
@@ -41,29 +41,14 @@ int hvc_get_chars(uint32_t vtermno, char
 	unsigned long got;
 
 	if (plpar_hcall(H_GET_TERM_CHAR, vtermno, 0, 0, 0, &got,
-		(unsigned long *)buf, (unsigned long *)buf+1) == H_Success) {
-		/*
-		 * Work around a HV bug where it gives us a null
-		 * after every \r.  -- paulus
-		 */
-		if (got > 0) {
-			int i;
-			for (i = 1; i < got; ++i) {
-				if (buf[i] == 0 && buf[i-1] == '\r') {
-					--got;
-					if (i < got)
-						memmove(&buf[i], &buf[i+1],
-							got - i);
-				}
-			}
-		}
+		(unsigned long *)buf, (unsigned long *)buf+1) == H_Success)
 		return got;
-	}
 	return 0;
 }
 
 EXPORT_SYMBOL(hvc_get_chars);
 
+
 /**
  * hvc_put_chars: send characters to firmware for denoted vterm adapter
  * @vtermno: The vtermno or unit_address of the adapter from which the data
diff -puN drivers/char/hvc_vio.c~hvc-console-nul-filter drivers/char/hvc_vio.c
--- gr_work_small/drivers/char/hvc_vio.c~hvc-console-nul-filter	2005-05-31 22:06:09.000000000 -0500
+++ gr_work_small-miltonm/drivers/char/hvc_vio.c	2005-05-31 22:09:23.000000000 -0500
@@ -43,8 +43,30 @@ static struct vio_device_id hvc_driver_t
 };
 MODULE_DEVICE_TABLE(vio, hvc_driver_table);
 
+static int filtered_get_chars(uint32_t vtermno, char *buf, int count)
+{
+	unsigned long got;
+	int i;
+
+	got = hvc_get_chars(vtermno, buf, count);
+
+	/*
+	 * Work around a HV bug where it gives us a null
+	 * after every \r.  -- paulus
+	 */
+	for (i = 1; i < got; ++i) {
+		if (buf[i] == 0 && buf[i-1] == '\r') {
+			--got;
+			if (i < got)
+				memmove(&buf[i], &buf[i+1],
+					got - i);
+		}
+	}
+	return got;
+}
+
 static struct hv_ops hvc_get_put_ops = {
-	.get_chars = hvc_get_chars,
+	.get_chars = filtered_get_chars,
 	.put_chars = hvc_put_chars,
 };
 
_



More information about the Linuxppc64-dev mailing list