aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/kern_conf.c
diff options
context:
space:
mode:
authorPoul-Henning Kamp <phk@FreeBSD.org>2004-03-11 12:58:55 +0000
committerPoul-Henning Kamp <phk@FreeBSD.org>2004-03-11 12:58:55 +0000
commit9397290e76aa2221cbdf104cc46dafd3e9e779d4 (patch)
treed80c1ed0f5ff7fc7c422007db569eb63e1395ee9 /sys/kern/kern_conf.c
parent03f0d9e8ae6d98324d750f279801106df7b32877 (diff)
downloadsrc-9397290e76aa2221cbdf104cc46dafd3e9e779d4.tar.gz
src-9397290e76aa2221cbdf104cc46dafd3e9e779d4.zip
Add clone_setup() function rather than rely on lazy initialization.
Requested by: rwatson
Notes
Notes: svn path=/head/; revision=126845
Diffstat (limited to 'sys/kern/kern_conf.c')
-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 8f8d1a45c9ef..6ca948db7e01 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)) {