[PATCH 10/14] hvc_console: Separate hvc_console and vio code

Anton Blanchard anton at samba.org
Thu Jul 7 01:58:36 EST 2005


From: Milton Miller <miltonm at bga.com>

Separate the console setup routines of the hvc_console and the vio layer.

Remove the call to find_init_vty from hvc_console.c.

Fail the setup routine if the console doesn't exist, but register the
console again when the specified channel is instantiated.  This scheme
maintains the print buffer semantics while eliminating callout and call
back for the console code.

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-seperate-setup arch/ppc64/kernel/hvconsole.c
--- gr_work_small/arch/ppc64/kernel/hvconsole.c~hvc-console-seperate-setup	2005-05-31 21:12:30.000000000 -0500
+++ gr_work_small-miltonm/arch/ppc64/kernel/hvconsole.c	2005-06-01 20:01:51.205950334 -0500
@@ -93,7 +93,7 @@ EXPORT_SYMBOL(hvc_put_chars);
  * We hope/assume that the first vty found corresponds to the first console
  * device.
  */
-int hvc_find_vtys(void)
+static int hvc_find_vtys(void)
 {
 	struct device_node *vty;
 	int num_found = 0;
@@ -119,3 +119,4 @@ int hvc_find_vtys(void)
 
 	return num_found;
 }
+console_initcall(hvc_find_vtys);
diff -puN drivers/char/hvc_console.c~hvc-console-seperate-setup drivers/char/hvc_console.c
--- gr_work_small/drivers/char/hvc_console.c~hvc-console-seperate-setup	2005-05-31 21:12:30.000000000 -0500
+++ gr_work_small-miltonm/drivers/char/hvc_console.c	2005-06-01 20:01:51.197951605 -0500
@@ -219,10 +219,23 @@ struct console hvc_con_driver = {
 	.index		= -1,
 };
 
-/* Early console initialization.  Preceeds driver initialization. */
+/*
+ * Early console initialization.  Preceeds driver initialization.
+ *
+ * (1) we are first, and the user specified another driver
+ * -- index will remain -1
+ * (2) we are first and the user specified no driver
+ * -- index will be set to 0, then we will fail setup.
+ * (3)  we are first and the user specified our driver
+ * -- index will be set to user specified driver, and we will fail
+ * (4) we are after driver, and this initcall will register us
+ * -- if the user didn't specify a driver then the console will match
+ *
+ * Note that for cases 2 and 3, we will match later when the io driver
+ * calls hvc_instantiate() and call register again.
+ */
 static int __init hvc_console_init(void)
 {
-	hvc_find_vtys();
 	register_console(&hvc_con_driver);
 	return 0;
 }
@@ -257,6 +270,13 @@ int hvc_instantiate(uint32_t vtermno, in
 	if (last_hvc < index)
 		last_hvc = index;
 
+	/* if this index is what the user requested, then register
+	 * now (setup won't fail at this point).  It's ok to just
+	 * call register again if previously .setup failed.
+	 */
+	if (index == hvc_con_driver.index)
+		register_console(&hvc_con_driver);
+
 	return 0;
 }
 
diff -puN include/asm-ppc64/hvconsole.h~hvc-console-seperate-setup include/asm-ppc64/hvconsole.h
--- gr_work_small/include/asm-ppc64/hvconsole.h~hvc-console-seperate-setup	2005-05-31 21:12:30.000000000 -0500
+++ gr_work_small-miltonm/include/asm-ppc64/hvconsole.h	2005-06-01 20:01:51.204950493 -0500
@@ -32,9 +32,6 @@
 extern int hvc_get_chars(uint32_t vtermno, char *buf, int count);
 extern int hvc_put_chars(uint32_t vtermno, const char *buf, int count);
 
-/* Early discovery of console adapters. */
-extern int hvc_find_vtys(void);
-
-/* Implemented by a console driver */
+/* Register a vterm and a slot index for use as a console */
 extern int hvc_instantiate(uint32_t vtermno, int index);
 #endif /* _PPC64_HVCONSOLE_H */
_



More information about the Linuxppc64-dev mailing list