change 'struct device' and 'struct evcnt' lists (alldevs and allevents) to

be TAILQ's.  TAILQ_HEAD's of those structs are now 'struct devicelist' and
'struct evcntlist', respectively.
This commit is contained in:
cgd 1996-04-04 00:25:44 +00:00
parent ea39811fd8
commit 8c248b98cc
2 changed files with 28 additions and 12 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: subr_autoconf.c,v 1.19 1996/03/17 01:00:43 thorpej Exp $ */
/* $NetBSD: subr_autoconf.c,v 1.20 1996/04/04 00:25:49 cgd Exp $ */
/*
* Copyright (c) 1992, 1993
@ -77,6 +77,20 @@ struct matchinfo {
static char *number __P((char *, int));
static void mapply __P((struct matchinfo *, struct cfdata *));
struct devicelist alldevs; /* list of all devices */
struct evcntlist allevents; /* list of all event counters */
/*
* Initialize autoconfiguration data structures.
*/
void
config_init()
{
TAILQ_INIT(&alldevs);
TAILQ_INIT(&allevents);
}
/*
* Apply the matching function and choose the best. This is used
* a few times and we want to keep the code small.
@ -303,7 +317,6 @@ config_attach(parent, match, aux, print)
register struct device *dev;
register struct cfdriver *cd;
register struct cfattach *ca;
static struct device **nextp = &alldevs;
if (parent && parent->dv_cfdata->cf_driver->cd_indirect) {
dev = match;
@ -322,8 +335,7 @@ config_attach(parent, match, aux, print)
else
cf->cf_fstate = FSTATE_FOUND;
*nextp = dev; /* link up */
nextp = &dev->dv_next;
TAILQ_INSERT_TAIL(&alldevs, dev, dv_list);
if (parent == ROOT)
printf("%s (root)", dev->dv_xname);
@ -427,7 +439,6 @@ evcnt_attach(dev, name, ev)
const char *name;
struct evcnt *ev;
{
static struct evcnt **nextp = &allevents;
#ifdef DIAGNOSTIC
if (strlen(name) >= sizeof(ev->ev_name))
@ -437,6 +448,5 @@ evcnt_attach(dev, name, ev)
ev->ev_dev = dev;
/* ev->ev_count = 0; */
strcpy(ev->ev_name, name);
*nextp = ev;
nextp = &ev->ev_next;
TAILQ_INSERT_TAIL(&allevents, ev, ev_list);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: device.h,v 1.12 1996/03/17 01:03:02 thorpej Exp $ */
/* $NetBSD: device.h,v 1.13 1996/04/04 00:25:44 cgd Exp $ */
/*
* Copyright (c) 1992, 1993
@ -47,6 +47,8 @@
#ifndef _SYS_DEVICE_H_
#define _SYS_DEVICE_H_
#include <sys/queue.h>
/*
* Minimal device structures.
* Note that all ``system'' device types are listed here.
@ -62,20 +64,22 @@ enum devclass {
struct device {
enum devclass dv_class; /* this device's classification */
struct device *dv_next; /* next in list of all */
TAILQ_ENTRY(device) dv_list; /* entry on list of all devices */
struct cfdata *dv_cfdata; /* config data that found us */
int dv_unit; /* device unit number */
char dv_xname[16]; /* external name (name + unit) */
struct device *dv_parent; /* pointer to parent device */
};
TAILQ_HEAD(devicelist, device);
/* `event' counters (use zero or more per device instance, as needed) */
struct evcnt {
struct evcnt *ev_next; /* linked list */
TAILQ_ENTRY(evcnt) ev_list; /* entry on list of all counters */
struct device *ev_dev; /* associated device */
int ev_count; /* how many have occurred */
char ev_name[8]; /* what to call them (systat display) */
};
TAILQ_HEAD(evcntlist, evcnt);
/*
* Configuration data (i.e., data placed in ioconf.c).
@ -148,9 +152,11 @@ struct pdevinit {
};
#ifdef _KERNEL
struct device *alldevs; /* head of list of all devices */
struct evcnt *allevents; /* head of list of all events */
extern struct devicelist alldevs; /* list of all devices */
extern struct evcntlist allevents; /* list of all event counters */
void config_init __P((void));
void *config_search __P((cfmatch_t, struct device *, void *));
void *config_rootsearch __P((cfmatch_t, char *, void *));
int config_found_sm __P((struct device *, void *, cfprint_t, cfmatch_t));