Module Name:    src
Committed By:   tsutsui
Date:           Sun Jun 12 03:14:03 UTC 2011

Modified Files:
        src/sys/arch/emips/emips: autoconf.c

Log Message:
- misc KNF
- use device_xname(), device_unit(), and device_class()


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/emips/emips/autoconf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/emips/emips/autoconf.c
diff -u src/sys/arch/emips/emips/autoconf.c:1.3 src/sys/arch/emips/emips/autoconf.c:1.4
--- src/sys/arch/emips/emips/autoconf.c:1.3	Tue Feb 22 08:20:20 2011
+++ src/sys/arch/emips/emips/autoconf.c	Sun Jun 12 03:14:03 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.3 2011/02/22 08:20:20 matt Exp $	*/
+/*	$NetBSD: autoconf.c,v 1.4 2011/06/12 03:14:03 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.3 2011/02/22 08:20:20 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.4 2011/06/12 03:14:03 tsutsui Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -60,6 +60,7 @@
 void
 cpu_configure(void)
 {
+
 	/* Kick off autoconfiguration. */
 	(void)splhigh();
 
@@ -80,56 +81,63 @@
 /*
  * Look at the string 'cp' and decode the boot device.
  * Boot names are something like '0/ace(0,0)/netbsd' or 'tftp()/nfsnetbsd'
- * meaning: [BusNumber/]<ControllerName>([<DiskNumber>,<PartitionNumber])/<kernelname>
+ * meaning:
+ *  [BusNumber/]<ControllerName>([<DiskNumber>,<PartitionNumber])/<kernelname>
  */
 void
 makebootdev(char *cp)
 {
-    int i;
-    static char booted_controller_name[8];
+	int i;
+	static char booted_controller_name[8];
 
 	booted_device = NULL;
 	booted_bus = booted_unit = booted_partition = 0;
 	booted_controller = NULL;
 
-    if (*cp >= '0' && *cp <= '9') {
-        booted_bus = *cp++ - '0';
-        if (*cp == '/') cp++;
-    }
+	if (*cp >= '0' && *cp <= '9') {
+	        booted_bus = *cp++ - '0';
+		if (*cp == '/')
+			cp++;
+	}
 
 	if (strncmp(cp, "tftp(", 5) == 0) {
 		booted_controller = "BOOTP";
 		goto out;
 	}
 
-    /* Stash away the controller name and use it later
-     */
-    for (i = 0; i < 7 && *cp && *cp != '('; i++)
-        booted_controller_name[i] = *cp++;
-    booted_controller_name[7] = 0; /* sanity */
-
-    if (*cp == '(') cp++;
-    if (*cp >= '0' && *cp <= '9') 
-        booted_unit = *cp++ - '0';
-
-    if (*cp == ',') cp++;
-    if (*cp >= '0' && *cp <= '9')
-        booted_partition = *cp - '0';
-    booted_controller = booted_controller_name;
+	/*
+	 * Stash away the controller name and use it later
+	 */
+	for (i = 0; i < 7 && *cp && *cp != '('; i++)
+		booted_controller_name[i] = *cp++;
+	booted_controller_name[7] = 0; /* sanity */
+
+	if (*cp == '(')
+		cp++;
+	if (*cp >= '0' && *cp <= '9') 
+		booted_unit = *cp++ - '0';
+
+	if (*cp == ',')
+		cp++;
+	if (*cp >= '0' && *cp <= '9')
+		booted_partition = *cp - '0';
+	booted_controller = booted_controller_name;
 
  out:
 #if DEBUG
-    printf("bootdev: %d/%s(%d,%d)\n",booted_bus,booted_controller,booted_unit,booted_partition);
+	printf("bootdev: %d/%s(%d,%d)\n",
+	    booted_bus, booted_controller, booted_unit, booted_partition);
 #endif
-    return;
+	return;
 }
 
 void
 cpu_rootconf(void)
 {
+
 	printf("boot device: %s part%d\n",
-	    booted_device ? booted_device->dv_xname : "<unknown>",
-           booted_partition);
+	    booted_device ? device_xname(booted_device) : "<unknown>",
+	    booted_partition);
 
 	setroot(booted_device, booted_partition);
 }
@@ -138,18 +146,18 @@
  * Try to determine the boot device.
  */
 void
-device_register(struct device *dev,
-                void *aux)
+device_register(device_t dev, void *aux)
 {
 	static int found, initted, netboot;
-	static struct device *ebusdev;
-	struct device *parent = device_parent(dev);
+	static device_t ebusdev;
+	device_t parent = device_parent(dev);
 
 	if (found)
 		return;
 
 #if 0
-    printf("\n[device_register(%s,%d) class %d]\n", dev->dv_xname, dev->dv_unit, dev->dv_class);
+	printf("\n[device_register(%s,%d) class %d]\n",
+	    device_xname(dev), device_unit(dev), device_class(dev));
 #endif
 
 	if (!initted) {
@@ -161,7 +169,7 @@
 	 * Remember the EBUS
 	 */
 	if (device_is_a(dev, "ebus")) {
-        ebusdev = dev;
+		ebusdev = dev;
 		return;
 	}
 
@@ -170,9 +178,9 @@
 	 */
 	if (netboot) {
 
-        /* Only one Ethernet interface (on ebus). */
-		if ((parent == ebusdev)
-		    && device_is_a(dev, "enic")) {
+		/* Only one Ethernet interface (on ebus). */
+		if ((parent == ebusdev) &&
+		    device_is_a(dev, "enic")) {
 			booted_device = dev;
 			found = 1;
 			return;
@@ -186,15 +194,15 @@
 			return;
 		}
 
-        /* The NIC might be found after the disk, so bail out here */
-        return;
+		/* The NIC might be found after the disk, so bail out here */
+		return;
 	}
 
-    /* BUGBUG How would I get to the bus */
-    if (device_is_a(dev,booted_controller) && (dev->dv_unit == booted_unit)) {
-        booted_device = dev;
-        found = 1;
-        return;
-    }
-
+	/* BUGBUG How would I get to the bus */
+	if (device_is_a(dev, booted_controller) &&
+	    (device_unit(dev) == booted_unit)) {
+		booted_device = dev;
+		found = 1;
+		return;
+	}
 }

Reply via email to