diff options
author | ed <ed@FreeBSD.org> | 2008-05-29 12:50:46 +0000 |
---|---|---|
committer | ed <ed@FreeBSD.org> | 2008-05-29 12:50:46 +0000 |
commit | 5de6a45e07a5027a8c6df5a9c354fbfd9c76aec1 (patch) | |
tree | ca425ff2b259e162d9f380346730fb449b867997 /sys | |
parent | 68f17e9b6872a274fd98ed5d52f202e5157b39df (diff) | |
download | FreeBSD-src-5de6a45e07a5027a8c6df5a9c354fbfd9c76aec1.zip FreeBSD-src-5de6a45e07a5027a8c6df5a9c354fbfd9c76aec1.tar.gz |
Remove the distinction between device minor and unit numbers.
Even though we got rid of device major numbers some time ago, device
drivers still need to provide unique device minor numbers to make_dev().
These numbers are only used inside the kernel. They are not related to
device major and minor numbers which are visible in devfs. These are
actually based on the inode number of the device.
It would eventually be nice to remove minor numbers entirely, but we
don't want to be too agressive here.
Because the 8-15 bits of the device number field (si_drv0) are still
reserved for the major number, there is no 1:1 mapping of the device
minor and unit numbers. Because this is now unused, remove the
restrictions on these numbers.
The MAXMAJOR definition was actually used for two purposes. It was used
to convert both the userspace and kernelspace device numbers to their
major/minor pair, which is why it is now named UMINORMASK.
minor2unit() and unit2minor() have now become useless. Both minor() and
dev2unit() now serve the same purpose. We should eventually remove some
of them, at least turning them into macro's. If devfs would become
completely minor number unaware, we could consider using si_drv0 directly,
just like si_drv1 and si_drv2.
Approved by: philip (mentor)
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/ieee488/upd7210.c | 2 | ||||
-rw-r--r-- | sys/dev/led/led.c | 3 | ||||
-rw-r--r-- | sys/dev/md/md.c | 3 | ||||
-rw-r--r-- | sys/geom/geom_dev.c | 2 | ||||
-rw-r--r-- | sys/kern/kern_conf.c | 19 | ||||
-rw-r--r-- | sys/sys/conf.h | 2 |
6 files changed, 14 insertions, 17 deletions
diff --git a/sys/dev/ieee488/upd7210.c b/sys/dev/ieee488/upd7210.c index c014f9f..27359e2 100644 --- a/sys/dev/ieee488/upd7210.c +++ b/sys/dev/ieee488/upd7210.c @@ -277,7 +277,7 @@ upd7210attach(struct upd7210 *u) struct cdev *dev; if (units == NULL) - units = new_unrhdr(0, minor2unit(MAXMINOR), NULL); + units = new_unrhdr(0, INT_MAX, NULL); u->unit = alloc_unr(units); mtx_init(&u->mutex, "gpib", NULL, MTX_DEF); u->cdev = make_dev(&gpib_l_cdevsw, u->unit, diff --git a/sys/dev/led/led.c b/sys/dev/led/led.c index b9aae50..73af18a 100644 --- a/sys/dev/led/led.c +++ b/sys/dev/led/led.c @@ -15,6 +15,7 @@ __FBSDID("$FreeBSD$"); #include <sys/conf.h> #include <sys/kernel.h> #include <sys/systm.h> +#include <sys/limits.h> #include <sys/malloc.h> #include <sys/ctype.h> #include <sys/sbuf.h> @@ -298,7 +299,7 @@ static void led_drvinit(void *unused) { - led_unit = new_unrhdr(0, minor2unit(MAXMINOR), NULL); + led_unit = new_unrhdr(0, INT_MAX, NULL); mtx_init(&led_mtx, "LED mtx", NULL, MTX_DEF); sx_init(&led_sx, "LED sx"); callout_init(&led_ch, CALLOUT_MPSAFE); diff --git a/sys/dev/md/md.c b/sys/dev/md/md.c index 639f4d8..93b407d 100644 --- a/sys/dev/md/md.c +++ b/sys/dev/md/md.c @@ -64,6 +64,7 @@ #include <sys/fcntl.h> #include <sys/kernel.h> #include <sys/kthread.h> +#include <sys/limits.h> #include <sys/linker.h> #include <sys/lock.h> #include <sys/malloc.h> @@ -1234,7 +1235,7 @@ g_md_init(struct g_class *mp __unused) md_preloaded(ptr, len); sx_xunlock(&md_sx); } - status_dev = make_dev(&mdctl_cdevsw, MAXMINOR, UID_ROOT, GID_WHEEL, + status_dev = make_dev(&mdctl_cdevsw, INT_MAX, UID_ROOT, GID_WHEEL, 0600, MDCTL_NAME); g_topology_lock(); } diff --git a/sys/geom/geom_dev.c b/sys/geom/geom_dev.c index c379d06..4abbfc0 100644 --- a/sys/geom/geom_dev.c +++ b/sys/geom/geom_dev.c @@ -88,7 +88,7 @@ static void g_dev_init(struct g_class *mp) { - unithdr = new_unrhdr(0, minor2unit(MAXMINOR), NULL); + unithdr = new_unrhdr(0, INT_MAX, NULL); } void diff --git a/sys/kern/kern_conf.c b/sys/kern/kern_conf.c index d4a421c..39cc8a7 100644 --- a/sys/kern/kern_conf.c +++ b/sys/kern/kern_conf.c @@ -501,7 +501,7 @@ minor(struct cdev *x) { if (x == NULL) return NODEV; - return(x->si_drv0 & MAXMINOR); + return (x->si_drv0); } int @@ -510,23 +510,21 @@ dev2unit(struct cdev *x) if (x == NULL) return NODEV; - return (minor2unit(minor(x))); + return (x->si_drv0); } u_int minor2unit(u_int _minor) { - KASSERT((_minor & ~MAXMINOR) == 0, ("Illegal minor %x", _minor)); - return ((_minor & 0xff) | ((_minor >> 8) & 0xffff00)); + return (_minor); } int unit2minor(int unit) { - KASSERT(unit <= 0xffffff, ("Invalid unit (%d) in unit2minor", unit)); - return ((unit & 0xff) | ((unit << 8) & ~0xffff)); + return (unit); } static void @@ -580,16 +578,18 @@ newdev(struct cdevsw *csw, int y, struct cdev *si) return (si); } +#define UMINORMASK 0xffff00ffU + int uminor(dev_t dev) { - return (dev & MAXMINOR); + return (dev & UMINORMASK); } int umajor(dev_t dev) { - return ((dev & ~MAXMINOR) >> 8); + return ((dev & ~UMINORMASK) >> 8); } static void @@ -697,9 +697,6 @@ make_dev_credv(int flags, struct cdevsw *devsw, int minornr, struct cdev *dev; int i; - KASSERT((minornr & ~MAXMINOR) == 0, - ("Invalid minor (0x%x) in make_dev", minornr)); - dev = devfs_alloc(); dev_lock(); prep_cdevsw(devsw); diff --git a/sys/sys/conf.h b/sys/sys/conf.h index 3b4e174..b9ba8fd 100644 --- a/sys/sys/conf.h +++ b/sys/sys/conf.h @@ -223,8 +223,6 @@ struct cdevsw { #define NUMCDEVSW 256 -#define MAXMINOR 0xffff00ffU - struct module; struct devsw_module_data { |