summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2004-03-11 12:58:55 +0000
committerphk <phk@FreeBSD.org>2004-03-11 12:58:55 +0000
commitfdd216910ffbe9a4c619c30e436cc4494c4aa76d (patch)
treed80c1ed0f5ff7fc7c422007db569eb63e1395ee9
parent0016f83af98e16cda533c5adf275ca76c3ac2362 (diff)
downloadFreeBSD-src-fdd216910ffbe9a4c619c30e436cc4494c4aa76d.zip
FreeBSD-src-fdd216910ffbe9a4c619c30e436cc4494c4aa76d.tar.gz
Add clone_setup() function rather than rely on lazy initialization.
Requested by: rwatson
-rw-r--r--sys/dev/nmdm/nmdm.c1
-rw-r--r--sys/dev/snp/snp.c1
-rw-r--r--sys/kern/kern_conf.c22
-rw-r--r--sys/net/if_tap.c1
-rw-r--r--sys/net/if_tun.c1
-rw-r--r--sys/sys/conf.h1
-rw-r--r--sys/sys/linedisc.h1
7 files changed, 19 insertions, 9 deletions
diff --git a/sys/dev/nmdm/nmdm.c b/sys/dev/nmdm/nmdm.c
index 22b9b51..841495f 100644
--- a/sys/dev/nmdm/nmdm.c
+++ b/sys/dev/nmdm/nmdm.c
@@ -594,6 +594,7 @@ nmdm_modevent(module_t mod, int type, void *data)
switch(type) {
case MOD_LOAD:
+ clone_setup(&nmdmclones);
tag = EVENTHANDLER_REGISTER(dev_clone, nmdm_clone, 0, 1000);
if (tag == NULL)
return (ENOMEM);
diff --git a/sys/dev/snp/snp.c b/sys/dev/snp/snp.c
index 19dc1e7..ebf888e 100644
--- a/sys/dev/snp/snp.c
+++ b/sys/dev/snp/snp.c
@@ -631,6 +631,7 @@ snp_modevent(mod, type, data)
switch (type) {
case MOD_LOAD:
/* XXX error checking. */
+ clone_setup(&snpclones);
eh_tag = EVENTHANDLER_REGISTER(dev_clone, snp_clone, 0, 1000);
snooplinedisc = ldisc_register(LDISC_LOAD, &snpdisc);
break;
diff --git a/sys/kern/kern_conf.c b/sys/kern/kern_conf.c
index 8f8d1a4..6ca948d 100644
--- a/sys/kern/kern_conf.c
+++ b/sys/kern/kern_conf.c
@@ -693,6 +693,14 @@ struct clonedevs {
LIST_HEAD(,cdev) head;
};
+void
+clone_setup(struct clonedevs **cdp)
+{
+
+ *cdp = malloc(sizeof **cdp, M_DEVBUF, M_WAITOK | M_ZERO);
+ LIST_INIT(&(*cdp)->head);
+}
+
int
clone_create(struct clonedevs **cdp, struct cdevsw *csw, int *up, dev_t *dp, u_int extra)
{
@@ -700,20 +708,15 @@ clone_create(struct clonedevs **cdp, struct cdevsw *csw, int *up, dev_t *dp, u_i
dev_t dev, dl, de;
int unit, low, u;
+ KASSERT(*cdp != NULL,
+ ("clone_setup() not called in driver \"%s\"", csw->d_name));
KASSERT(!(extra & CLONE_UNITMASK),
- ("Illegal extra bits (0x%x) in clone_create", extra));
+ ("Illegal extra bits (0x%x) in clone_create", extra));
KASSERT(*up <= CLONE_UNITMASK,
- ("Too high unit (0x%x) in clone_create", *up));
+ ("Too high unit (0x%x) in clone_create", *up));
if (csw->d_maj == MAJOR_AUTO)
find_major(csw);
- /* if clonedevs have not been initialized, we do it here */
- cd = *cdp;
- if (cd == NULL) {
- cd = malloc(sizeof *cd, M_DEVBUF, M_WAITOK | M_ZERO);
- LIST_INIT(&cd->head);
- *cdp = cd;
- }
/*
* Search the list for a lot of things in one go:
@@ -726,6 +729,7 @@ clone_create(struct clonedevs **cdp, struct cdevsw *csw, int *up, dev_t *dp, u_i
unit = *up;
low = 0;
de = dl = NULL;
+ cd = *cdp;
LIST_FOREACH(dev, &cd->head, si_clone) {
u = dev2unit(dev);
if (u == (unit | extra)) {
diff --git a/sys/net/if_tap.c b/sys/net/if_tap.c
index 8b40b45..59258c7 100644
--- a/sys/net/if_tap.c
+++ b/sys/net/if_tap.c
@@ -140,6 +140,7 @@ tapmodevent(mod, type, data)
SLIST_INIT(&taphead);
+ clone_setup(&tapclones);
eh_tag = EVENTHANDLER_REGISTER(dev_clone, tapclone, 0, 1000);
if (eh_tag == NULL)
return (ENOMEM);
diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c
index 222ce42..3bedf1c 100644
--- a/sys/net/if_tun.c
+++ b/sys/net/if_tun.c
@@ -150,6 +150,7 @@ tunmodevent(module_t mod, int type, void *data)
switch (type) {
case MOD_LOAD:
+ clone_setup(&tunclones);
tag = EVENTHANDLER_REGISTER(dev_clone, tunclone, 0, 1000);
if (tag == NULL)
return (ENOMEM);
diff --git a/sys/sys/conf.h b/sys/sys/conf.h
index 40ee4c3..f699882 100644
--- a/sys/sys/conf.h
+++ b/sys/sys/conf.h
@@ -297,6 +297,7 @@ static moduledata_t name##_mod = { \
DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE)
+void clone_setup(struct clonedevs **cdp);
void clone_cleanup(struct clonedevs **);
#define CLONE_UNITMASK 0xfffff
#define CLONE_FLAG0 (CLONE_UNITMASK + 1)
diff --git a/sys/sys/linedisc.h b/sys/sys/linedisc.h
index 40ee4c3..f699882 100644
--- a/sys/sys/linedisc.h
+++ b/sys/sys/linedisc.h
@@ -297,6 +297,7 @@ static moduledata_t name##_mod = { \
DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE)
+void clone_setup(struct clonedevs **cdp);
void clone_cleanup(struct clonedevs **);
#define CLONE_UNITMASK 0xfffff
#define CLONE_FLAG0 (CLONE_UNITMASK + 1)
OpenPOWER on IntegriCloud