patch-2.1.97 linux/arch/sparc64/prom/init.c

Next file: linux/arch/sparc64/prom/ranges.c
Previous file: linux/arch/sparc64/prom/bootstr.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.96/linux/arch/sparc64/prom/init.c linux/arch/sparc64/prom/init.c
@@ -1,4 +1,4 @@
-/* $Id: init.c,v 1.7 1997/03/24 17:43:59 jj Exp $
+/* $Id: init.c,v 1.8 1998/03/15 10:14:44 ecd Exp $
  * init.c:  Initialize internal variables used by the PROM
  *          library functions.
  *
@@ -9,6 +9,7 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/string.h>
+#include <linux/ctype.h>
 
 #include <asm/openprom.h>
 #include <asm/oplib.h>
@@ -32,11 +33,13 @@
 
 __initfunc(void prom_init(void *cif_handler, void *cif_stack))
 {
-	char buffer[80];
+	char buffer[80], *p;
+	int ints[3];
 	int node;
-	
+	int i = 0;
+
 	prom_vers = PROM_P1275;
-	
+
 	prom_cif_init(cif_handler, cif_stack);
 
 	prom_root_node = prom_getsibling(0);
@@ -46,34 +49,45 @@
 	prom_chosen_node = prom_finddevice("/chosen");
 	if (!prom_chosen_node || prom_chosen_node == -1)
 		prom_halt();
-		
+
 	prom_stdin = prom_getint (prom_chosen_node, "stdin");
 	prom_stdout = prom_getint (prom_chosen_node, "stdout");
 
 	node = prom_finddevice("/openprom");
 	if (!node || node == -1)
 		prom_halt();
-		
+
 	prom_getstring (node, "version", buffer, sizeof (buffer));
-	
+
 	prom_printf ("\n");
-	
-	if (strncmp (buffer, "OBP ", 4) || buffer[5] != '.' || buffer[7] != '.') {
-		prom_printf ("Strange OBP version `%s'.\n", buffer);
-		prom_halt ();
+
+	if (strncmp (buffer, "OBP ", 4))
+		goto strange_version;
+
+	/* Version field is expected to be 'OBP xx.yy.zz date...' */
+
+	p = buffer + 4;
+	while (p && isdigit(*p) && i < 3) {
+		ints[i++] = simple_strtoul(p, NULL, 0);
+		if ((p = strchr(p, '.')) != NULL)
+			p++;
 	}
-	/* Version field is expected to be 'OBP x.y.z date...' */
-	
-	prom_rev = buffer[6] - '0';
-	prom_prev = ((buffer[4] - '0') << 16) | 
-		    ((buffer[6] - '0') << 8) |
-		    (buffer[8] - '0');
-		    
+	if (i != 3)
+		goto strange_version;
+
+	prom_rev = ints[1];
+	prom_prev = (ints[0] << 16) | (ints[1] << 8) | ints[2];
+
 	printk ("PROMLIB: Sun IEEE Boot Prom %s\n", buffer + 4);
-	
+
 	prom_meminit();
 
 	prom_ranges_init();
 
 	/* Initialization successful. */
+	return;
+
+strange_version:
+	prom_printf ("Strange OBP version `%s'.\n", buffer);
+	prom_halt ();
 }

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov