Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/emips/emips - misc KNF



details:   https://anonhg.NetBSD.org/src/rev/8e7f63871f13
branches:  trunk
changeset: 765952:8e7f63871f13
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Sun Jun 12 03:14:03 2011 +0000

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

diffstat:

 sys/arch/emips/emips/autoconf.c |  94 ++++++++++++++++++++++------------------
 1 files changed, 51 insertions(+), 43 deletions(-)

diffs (184 lines):

diff -r 216acb3352ef -r 8e7f63871f13 sys/arch/emips/emips/autoconf.c
--- a/sys/arch/emips/emips/autoconf.c   Sun Jun 12 01:45:00 2011 +0000
+++ b/sys/arch/emips/emips/autoconf.c   Sun Jun 12 03:14:03 2011 +0000
@@ -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 */
+       /*
+        * 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_unit = *cp++ - '0';
 
-    if (*cp == ',') cp++;
-    if (*cp >= '0' && *cp <= '9')
-        booted_partition = *cp - '0';
-    booted_controller = booted_controller_name;
+       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;
+       }
 }



Home | Main Index | Thread Index | Old Index