summaryrefslogtreecommitdiffstats
path: root/sys/kern
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 /sys/kern
parent0016f83af98e16cda533c5adf275ca76c3ac2362 (diff)
downloadFreeBSD-src-fdd216910ffbe9a4c619c30e436cc4494c4aa76d.zip
FreeBSD-src-fdd216910ffbe9a4c619c30e436cc4494c4aa76d.tar.gz
Add clone_setup() function rather than rely on lazy initialization.
Requested by: rwatson
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/kern_conf.c22
1 files changed, 13 insertions, 9 deletions
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)) {
OpenPOWER on IntegriCloud