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/kern/kern_conf.c | |
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/kern/kern_conf.c')
-rw-r--r-- | sys/kern/kern_conf.c | 19 |
1 files changed, 8 insertions, 11 deletions
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); |