Source-Changes-HG archive

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

[src/trunk]: src/sys/arch CFATTACH_DECL(..., sizeof(struct device), -> CFATTA...



details:   https://anonhg.NetBSD.org/src/rev/9bb4ee41f549
branches:  trunk
changeset: 765806:9bb4ee41f549
user:      matt <matt%NetBSD.org@localhost>
date:      Mon Jun 06 17:13:05 2011 +0000

description:
CFATTACH_DECL(..., sizeof(struct device), -> CFATTACH_DECL_NEW(..., 0
struct device * -> device_t
struct cfdata * -> cfdata_t
use bool when appropriate
some constification

diffstat:

 sys/arch/evbmips/malta/dev/gt.c      |  20 +++++++++-----------
 sys/arch/evbmips/malta/dev/mainbus.c |  27 +++++++++++++--------------
 sys/arch/evbmips/malta/pci/pchb.c    |  18 +++++++++---------
 sys/arch/evbppc/explora/dev/elb.c    |  36 +++++++++++++++++++-----------------
 sys/arch/evbppc/walnut/pci/pchb.c    |   8 ++++----
 sys/arch/hpcmips/tx/txioman.c        |  18 +++++++++---------
 sys/arch/mips/alchemy/dev/auaudio.c  |  14 +++++++-------
 sys/arch/mipsco/obio/obio.c          |  24 ++++++++++++------------
 8 files changed, 82 insertions(+), 83 deletions(-)

diffs (truncated from 520 to 300 lines):

diff -r b5d369b65158 -r 9bb4ee41f549 sys/arch/evbmips/malta/dev/gt.c
--- a/sys/arch/evbmips/malta/dev/gt.c   Mon Jun 06 17:02:29 2011 +0000
+++ b/sys/arch/evbmips/malta/dev/gt.c   Mon Jun 06 17:13:05 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: gt.c,v 1.12 2011/05/17 17:34:49 dyoung Exp $   */
+/*     $NetBSD: gt.c,v 1.13 2011/06/06 17:13:05 matt Exp $     */
 
 /*
  * Copyright 2002 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: gt.c,v 1.12 2011/05/17 17:34:49 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gt.c,v 1.13 2011/06/06 17:13:05 matt Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -58,8 +58,7 @@
 #define        PCI_CONF_LOCK(s)        (s) = splhigh()
 #define        PCI_CONF_UNLOCK(s)      splx((s))
 
-static void    gt_attach_hook(struct device *, struct device *,
-                   struct pcibus_attach_args *);
+static void    gt_attach_hook(device_t, device_t, struct pcibus_attach_args *);
 static int     gt_bus_maxdevs(void *, int);
 static pcitag_t        gt_make_tag(void *, int, int, int);
 static void    gt_decompose_tag(void *, pcitag_t, int *, int *, int *);
@@ -80,28 +79,27 @@
 }
 
 static void
-gt_attach_hook(struct device *parent, struct device *self,
-    struct pcibus_attach_args *pba)
+gt_attach_hook(device_t parent, device_t self, struct pcibus_attach_args *pba)
 {
 
        /* Nothing to do... */
 }
 
-static int     gt_match(struct device *, struct cfdata *, void *);
-static void    gt_attach(struct device *, struct device *, void *);
+static int     gt_match(device_t, cfdata_t, void *);
+static void    gt_attach(device_t, device_t, void *);
 static int     gt_print(void *aux, const char *pnp);
 
-CFATTACH_DECL(gt, sizeof(struct device),
+CFATTACH_DECL_NEW(gt, 0,
     gt_match, gt_attach, NULL, NULL);
 
 static int
-gt_match(struct device *parent, struct cfdata *match, void *aux)
+gt_match(device_t parent, cfdata_t match, void *aux)
 {
        return 1;
 }
 
 static void
-gt_attach(struct device *parent, struct device *self, void *aux)
+gt_attach(device_t parent, device_t self, void *aux)
 {
        struct malta_config *mcp = &malta_configuration;
        struct pcibus_attach_args pba;
diff -r b5d369b65158 -r 9bb4ee41f549 sys/arch/evbmips/malta/dev/mainbus.c
--- a/sys/arch/evbmips/malta/dev/mainbus.c      Mon Jun 06 17:02:29 2011 +0000
+++ b/sys/arch/evbmips/malta/dev/mainbus.c      Mon Jun 06 17:13:05 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mainbus.c,v 1.11 2009/03/14 15:36:06 dsl Exp $ */
+/*     $NetBSD: mainbus.c,v 1.12 2011/06/06 17:13:05 matt Exp $        */
 
 /*
  * Copyright 2002 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.11 2009/03/14 15:36:06 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.12 2011/06/06 17:13:05 matt Exp $");
 
 #include "opt_pci.h"
 
@@ -67,17 +67,16 @@
 #include "locators.h"
 #include "pci.h"
 
-static int     mainbus_match(struct device *, struct cfdata *, void *);
-static void    mainbus_attach(struct device *, struct device *, void *);
-static int     mainbus_submatch(struct device *, struct cfdata *,
-                                const int *, void *);
+static int     mainbus_match(device_t, cfdata_t, void *);
+static void    mainbus_attach(device_t, device_t, void *);
+static int     mainbus_submatch(device_t, cfdata_t, const int *, void *);
 static int     mainbus_print(void *, const char *);
 
-CFATTACH_DECL(mainbus, sizeof(struct device),
+CFATTACH_DECL_NEW(mainbus, 0,
     mainbus_match, mainbus_attach, NULL, NULL);
 
 /* There can be only one. */
-int    mainbus_found;
+bool mainbus_found;
 
 struct mainbusdev {
        const char *md_name;
@@ -85,7 +84,7 @@
        int md_intr;
 };
 
-struct mainbusdev mainbusdevs[] = {
+const struct mainbusdev mainbusdevs[] = {
        { "cpu",                -1,                     -1 },
        { "gt",                 MALTA_CORECTRL_BASE,    -1 },
        { "com",                MALTA_CBUSUART,         MALTA_CBUSUART_INTR },
@@ -95,7 +94,7 @@
 };
 
 static int
-mainbus_match(struct device *parent, struct cfdata *match, void *aux)
+mainbus_match(device_t parent, cfdata_t match, void *aux)
 {
 
        if (mainbus_found)
@@ -105,10 +104,10 @@
 }
 
 static void
-mainbus_attach(struct device *parent, struct device *self, void *aux)
+mainbus_attach(device_t parent, device_t self, void *aux)
 {
        struct mainbus_attach_args ma;
-       struct mainbusdev *md;
+       const struct mainbusdev *md;
 #if defined(PCI_NETBSD_CONFIGURE)
        struct extent *ioext, *memext;
 #endif
@@ -119,7 +118,7 @@
        pcireg_t idetim;
 #endif
 
-       mainbus_found = 1;
+       mainbus_found = true;
        printf("\n");
 
 #if defined(PCI_NETBSD_CONFIGURE)
@@ -162,7 +161,7 @@
 }
 
 static int
-mainbus_submatch(struct device *parent, struct cfdata *cf,
+mainbus_submatch(device_t parent, cfdata_t cf,
                 const int *ldesc, void *aux)
 {
        struct mainbus_attach_args *ma = aux;
diff -r b5d369b65158 -r 9bb4ee41f549 sys/arch/evbmips/malta/pci/pchb.c
--- a/sys/arch/evbmips/malta/pci/pchb.c Mon Jun 06 17:02:29 2011 +0000
+++ b/sys/arch/evbmips/malta/pci/pchb.c Mon Jun 06 17:13:05 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pchb.c,v 1.9 2006/08/22 21:42:19 riz Exp $     */
+/*     $NetBSD: pchb.c,v 1.10 2011/06/06 17:13:05 matt Exp $   */
 
 /*
  * Copyright 2002 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pchb.c,v 1.9 2006/08/22 21:42:19 riz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pchb.c,v 1.10 2011/06/06 17:13:05 matt Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -45,16 +45,16 @@
 #include <dev/pci/pcivar.h>
 #include <dev/pci/pcidevs.h>
 
-static int     pchb_match(struct device *, struct cfdata *, void *);
-static void    pchb_attach(struct device *, struct device *, void *);
+static int     pchb_match(device_t, cfdata_t, void *);
+static void    pchb_attach(device_t, device_t, void *);
 
-CFATTACH_DECL(pchb, sizeof(struct device),
+CFATTACH_DECL_NEW(pchb, 0,
     pchb_match, pchb_attach, NULL, NULL);
 
-static int pcifound = 0;
+static bool pcifound;
 
 static int
-pchb_match(struct device *parent, struct cfdata *match, void *aux)
+pchb_match(device_t parent, cfdata_t match, void *aux)
 {
        struct pci_attach_args *pa = aux;
 
@@ -76,13 +76,13 @@
 }
 
 static void
-pchb_attach(struct device *parent, struct device *self, void *aux)
+pchb_attach(device_t parent, device_t self, void *aux)
 {
        struct pci_attach_args *pa = aux;
        char devinfo[256];
 
        printf("\n");
-       pcifound++;
+       pcifound = true;
 
        /*
         * All we do is print out a description.  Eventually, we
diff -r b5d369b65158 -r 9bb4ee41f549 sys/arch/evbppc/explora/dev/elb.c
--- a/sys/arch/evbppc/explora/dev/elb.c Mon Jun 06 17:02:29 2011 +0000
+++ b/sys/arch/evbppc/explora/dev/elb.c Mon Jun 06 17:13:05 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: elb.c,v 1.7 2011/06/06 16:42:17 matt Exp $     */
+/*     $NetBSD: elb.c,v 1.8 2011/06/06 17:13:06 matt Exp $     */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: elb.c,v 1.7 2011/06/06 16:42:17 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: elb.c,v 1.8 2011/06/06 17:13:06 matt Exp $");
 
 #include <sys/param.h>
 #include <sys/conf.h>
@@ -64,19 +64,20 @@
        BASE_PCKBC,
        BASE_PCKBC + 0x6ff
 };
-static char elb_ex_storage[EXTENT_FIXED_STORAGE_SIZE(8)]
-    __attribute__((aligned(8)));
-static int elb_tag_init_done;
-
 static struct powerpc_bus_space elb_fb_tag = {
        _BUS_SPACE_LITTLE_ENDIAN | _BUS_SPACE_MEM_TYPE,
        0x00000000,
        BASE_FB,
        BASE_FB2 + SIZE_FB - 1
 };
+
+static char elb_ex_storage[EXTENT_FIXED_STORAGE_SIZE(8)]
+    __attribute__((aligned(8)));
 static char elbfb_ex_storage[EXTENT_FIXED_STORAGE_SIZE(8)]
     __attribute__((aligned(8)));
-static int elbfb_tag_init_done;
+
+static bool elb_tag_init_done;
+static bool elbfb_tag_init_done;
 
 /*
  * DMA struct, nothing special.
@@ -100,7 +101,7 @@
        _bus_dma_bus_mem_to_phys_generic,
 };
 
-static struct elb_dev elb_devs[] = {
+static const struct elb_dev elb_devs[] = {
        { "cpu",        0,              0,              -1, NULL },
        { "pckbc",      BASE_PCKBC,     BASE_PCKBC2,    31, &elb_tag },
        { "com",        BASE_COM,       0,              30, &elb_tag },
@@ -128,16 +129,17 @@
 elb_attach(device_t parent, device_t self, void *aux)
 {
        struct elb_attach_args eaa;
-       int i;
+       const struct elb_dev *elb;
+       size_t i;
 
        printf("\n");
-       for (i = 0; i < sizeof(elb_devs)/sizeof(elb_devs[0]); i++) {
-               eaa.elb_name = elb_devs[i].elb_name;
-               eaa.elb_bt = elb_get_bus_space_tag(elb_devs[i].elb_addr);
+       for (i = 0, elb = elb_devs; i < __arraycount(elb_devs); i++, elb++) {
+               eaa.elb_name = elb->elb_name;
+               eaa.elb_bt = elb_get_bus_space_tag(elb->elb_addr);
                eaa.elb_dmat = &elb_bus_dma_tag;
-               eaa.elb_base = elb_devs[i].elb_addr;
-               eaa.elb_base2 = elb_devs[i].elb_addr2;
-               eaa.elb_irq = elb_devs[i].elb_irq;
+               eaa.elb_base = elb->elb_addr;
+               eaa.elb_base2 = elb->elb_addr2;
+               eaa.elb_irq = elb->elb_irq;
 
                (void) config_found(self, &eaa, elb_print);
        }
@@ -166,7 +168,7 @@
                            elb_ex_storage, sizeof(elb_ex_storage)))
                                panic("elb_get_bus_space_tag: elb_tag");
 
-                       elb_tag_init_done = 1;
+                       elb_tag_init_done = true;
                }
                return (&elb_tag);
        } else {
@@ -175,7 +177,7 @@
                            elbfb_ex_storage, sizeof(elbfb_ex_storage)))
                                panic("elb_get_bus_space_tag: elb_fb_tag");
 



Home | Main Index | Thread Index | Old Index