Add MAXMINOR #define, we should have had this long time ago.

Add minor2unit() in addition to dev2unit() and unit2minor().

If it wasn't such a hazzle we should redefine minor numbers in
the kernel without the gap for the major number, but it's not worth
the bother (yet).
This commit is contained in:
Poul-Henning Kamp 2005-01-29 15:07:13 +00:00
parent e697161fa2
commit 3a85fd262c
2 changed files with 12 additions and 3 deletions

View File

@ -258,12 +258,18 @@ minor(struct cdev *x)
int
dev2unit(struct cdev *x)
{
int i;
if (x == NULL)
return NODEV;
i = minor(x);
return ((i & 0xff) | (i >> 8));
return (minor2unit(minor(x));
}
int
minor2unit(int _minor)
{
KASSERT((_minor & 0xff00) == 0, ("Illegal minor %x", _minor));
return ((_minor & 0xff) | (_minor >> 8));
}
int

View File

@ -219,6 +219,8 @@ struct cdevsw {
#define NUMCDEVSW 256
#define MAXMINOR 0xffff00ff
/*
* XXX: do not use MAJOR_AUTO unless you have no choice. In general drivers
* should just not initialize .d_maj and that will DTRT.
@ -266,6 +268,7 @@ int dev2unit(struct cdev *_dev);
void dev_lock(void);
void dev_unlock(void);
int unit2minor(int _unit);
int minor2unit(int _minor);
void setconf(void);
void devfs_create(struct cdev *dev);