diff --git a/sys/fs/devfs/devfs_devs.c b/sys/fs/devfs/devfs_devs.c index 4db217d1d3bf..ef9827cf5e45 100644 --- a/sys/fs/devfs/devfs_devs.c +++ b/sys/fs/devfs/devfs_devs.c @@ -437,6 +437,6 @@ devfs_init(void *junk) devfs_present = 1; } -SYSINIT(devfs, SI_SUB_DRIVERS, SI_ORDER_FIRST, devfs_init, NULL); +SYSINIT(devfs, SI_SUB_DEVFS, SI_ORDER_FIRST, devfs_init, NULL); #endif diff --git a/sys/kern/kern_conf.c b/sys/kern/kern_conf.c index 552e67ebc638..a9264a252f28 100644 --- a/sys/kern/kern_conf.c +++ b/sys/kern/kern_conf.c @@ -71,6 +71,8 @@ devfs_create_t *devfs_create_hook; devfs_destroy_t *devfs_destroy_hook; int devfs_present; +static int ready_for_devs; + static int free_devt; SYSCTL_INT(_debug, OID_AUTO, free_devt, CTLFLAG_RW, &free_devt, 0, ""); @@ -288,6 +290,12 @@ make_dev(struct cdevsw *devsw, int minor, uid_t uid, gid_t gid, int perms, const KASSERT(umajor(makeudev(devsw->d_maj, minor)) == devsw->d_maj, ("Invalid minor (%d) in make_dev", minor)); + if (!ready_for_devs) { + printf("WARNING: Driver mistake: make_dev(%s) called before SI_SUB_DRIVERS\n", + fmt); + /* XXX panic here once drivers are cleaned up */ + } + dev = makedev(devsw->d_maj, minor); if (dev->si_flags & SI_NAMED) { printf( "WARNING: Driver mistake: repeat make_dev(\"%s\")\n", @@ -454,4 +462,14 @@ sysctl_devname(SYSCTL_HANDLER_ARGS) SYSCTL_PROC(_kern, OID_AUTO, devname, CTLTYPE_OPAQUE|CTLFLAG_RW|CTLFLAG_ANYBODY, NULL, 0, sysctl_devname, "", "devname(3) handler"); - + +/* + * Set ready_for_devs; prior to this point, device creation is not allowed. + */ +static void +dev_set_ready(void *junk) +{ + ready_for_devs = 1; +} + +SYSINIT(dev_ready, SI_SUB_DEVFS, SI_ORDER_FIRST, dev_set_ready, NULL); diff --git a/sys/sys/kernel.h b/sys/sys/kernel.h index 9943b1fe22a0..f86a638a06e9 100644 --- a/sys/sys/kernel.h +++ b/sys/sys/kernel.h @@ -130,6 +130,7 @@ enum sysinit_sub_id { SI_SUB_MBUF = 0x2700000, /* mbuf subsystem */ SI_SUB_INTR = 0x2800000, /* interrupt threads */ SI_SUB_SOFTINTR = 0x2800001, /* start soft interrupt thread */ + SI_SUB_DEVFS = 0x2F00000, /* devfs ready for devices */ SI_SUB_INIT_IF = 0x3000000, /* prep for net interfaces */ SI_SUB_DRIVERS = 0x3100000, /* Let Drivers initialize */ SI_SUB_CONFIGURE = 0x3800000, /* Configure devices */