Remove unit2minor() use from kernel code.

When I changed kern_conf.c three months ago I made device unit numbers
equal to (unneeded) device minor numbers. We used to require
bitshifting, because there were eight bits in the middle that were
reserved for a device major number. Not very long after I turned
dev2unit(), minor(), unit2minor() and minor2unit() into macro's.
The unit2minor() and minor2unit() macro's were no-ops.

We'd better not remove these four macro's from the kernel, because there
is a lot of (external) code that may still depend on them. For now it's
harmless to remove all invocations of unit2minor() and minor2unit().

Reviewed by:	kib
This commit is contained in:
Ed Schouten 2008-09-26 14:19:52 +00:00
parent ed0c85e094
commit d3ce832719
20 changed files with 25 additions and 25 deletions

View File

@ -265,7 +265,7 @@ passregister(struct cam_periph *periph, void *arg)
mtx_unlock(periph->sim->mtx);
no_tags = (cgd->inq_data.flags & SID_CmdQue) == 0;
softc->device_stats = devstat_new_entry("pass",
unit2minor(periph->unit_number), 0,
periph->unit_number, 0,
DEVSTAT_NO_BLOCKSIZE
| (no_tags ? DEVSTAT_NO_ORDERED_TAGS : 0),
softc->pd_type |
@ -274,7 +274,7 @@ passregister(struct cam_periph *periph, void *arg)
DEVSTAT_PRIORITY_PASS);
/* Register the device */
softc->dev = make_dev(&pass_cdevsw, unit2minor(periph->unit_number),
softc->dev = make_dev(&pass_cdevsw, periph->unit_number,
UID_ROOT, GID_OPERATOR, 0600, "%s%d",
periph->periph_name, periph->unit_number);
mtx_lock(periph->sim->mtx);

View File

@ -343,7 +343,7 @@ sesregister(struct cam_periph *periph, void *arg)
}
cam_periph_unlock(periph);
softc->ses_dev = make_dev(&ses_cdevsw, unit2minor(periph->unit_number),
softc->ses_dev = make_dev(&ses_cdevsw, periph->unit_number,
UID_ROOT, GID_OPERATOR, 0600, "%s%d",
periph->periph_name, periph->unit_number);
cam_periph_lock(periph);

View File

@ -287,7 +287,7 @@ sgregister(struct cam_periph *periph, void *arg)
cam_periph_unlock(periph);
no_tags = (cgd->inq_data.flags & SID_CmdQue) == 0;
softc->device_stats = devstat_new_entry("sg",
unit2minor(periph->unit_number), 0,
periph->unit_number, 0,
DEVSTAT_NO_BLOCKSIZE
| (no_tags ? DEVSTAT_NO_ORDERED_TAGS : 0),
softc->pd_type |
@ -296,7 +296,7 @@ sgregister(struct cam_periph *periph, void *arg)
DEVSTAT_PRIORITY_PASS);
/* Register the device */
softc->dev = make_dev(&sg_cdevsw, unit2minor(periph->unit_number),
softc->dev = make_dev(&sg_cdevsw, periph->unit_number,
UID_ROOT, GID_OPERATOR, 0600, "%s%d",
periph->periph_name, periph->unit_number);
(void)make_dev_alias(softc->dev, "sg%c", 'a' + periph->unit_number);

View File

@ -1031,7 +1031,7 @@ targclone(void *arg, struct ucred *cred, char *name, int namelen,
return;
if (dev_stdclone(name, NULL, "targ", &u) != 1)
return;
*dev = make_dev(&targ_cdevsw, unit2minor(u), UID_ROOT, GID_WHEEL,
*dev = make_dev(&targ_cdevsw, u, UID_ROOT, GID_WHEEL,
0600, "targ%d", u);
dev_ref(*dev);
(*dev)->si_flags |= SI_CHEAPCLONE;

View File

@ -52,7 +52,7 @@ dtrace_clone(void *arg, struct ucred *cred, char *name, int namelen, struct cdev
/* Clone the device to the new minor number. */
if (clone_create(&dtrace_clones, &dtrace_cdevsw, &u, dev, 0) != 0)
/* Create the /dev/dtrace/dtraceNN entry. */
*dev = make_dev_cred(&dtrace_cdevsw, unit2minor(u), cred,
*dev = make_dev_cred(&dtrace_cdevsw, u, cred,
UID_ROOT, GID_WHEEL, 0600, "dtrace/dtrace%d", u);
if (*dev != NULL) {
dev_ref(*dev);

View File

@ -257,7 +257,7 @@ led_create_state(led_t *func, void *priv, char const *name, int state)
sc->unit = alloc_unr(led_unit);
sc->private = priv;
sc->func = func;
sc->dev = make_dev(&led_cdevsw, unit2minor(sc->unit),
sc->dev = make_dev(&led_cdevsw, sc->unit,
UID_ROOT, GID_WHEEL, 0600, "led/%s", name);
sx_xunlock(&led_sx);

View File

@ -2313,7 +2313,7 @@ emu10kx_dev_init(struct emu_sc_info *sc)
mtx_init(&sc->emu10kx_lock, device_get_nameunit(sc->dev), "kxdevlock", 0);
unit = device_get_unit(sc->dev);
sc->cdev = make_dev(&emu10kx_cdevsw, unit2minor(unit), UID_ROOT, GID_WHEEL, 0640, "emu10kx%d", unit);
sc->cdev = make_dev(&emu10kx_cdevsw, unit, UID_ROOT, GID_WHEEL, 0640, "emu10kx%d", unit);
if (sc->cdev != NULL) {
sc->cdev->si_drv1 = sc;
return (0);

View File

@ -2096,7 +2096,7 @@ dsp_clone(void *arg,
snd_clone_setmaxunit(d->clones, tumax);
if (ce != NULL) {
udcmask |= snd_c2unit(cunit);
*dev = make_dev(&dsp_cdevsw, unit2minor(udcmask),
*dev = make_dev(&dsp_cdevsw, udcmask,
UID_ROOT, GID_WHEEL, 0666, "%s%d%s%d",
devname, unit, devsep, cunit);
snd_clone_register(ce, *dev);

View File

@ -644,7 +644,7 @@ mixer_init(device_t dev, kobj_class_t cls, void *devinfo)
unit = device_get_unit(dev);
devunit = snd_mkunit(unit, SND_DEV_CTL, 0);
pdev = make_dev(&mixer_cdevsw, unit2minor(devunit),
pdev = make_dev(&mixer_cdevsw, devunit,
UID_ROOT, GID_WHEEL, 0666, "mixer%d", unit);
pdev->si_drv1 = m;
snddev = device_get_softc(dev);

View File

@ -187,7 +187,7 @@ vkbd_dev_clone(void *arg, struct ucred *cred, char *name, int namelen,
/* find any existing device, or allocate new unit number */
if (clone_create(&vkbd_dev_clones, &vkbd_dev_cdevsw, &unit, dev, 0)) {
*dev = make_dev(&vkbd_dev_cdevsw, unit2minor(unit),
*dev = make_dev(&vkbd_dev_cdevsw, unit,
UID_ROOT, GID_WHEEL, 0600, DEVICE_NAME "%d", unit);
if (*dev != NULL) {
dev_ref(*dev);

View File

@ -127,7 +127,7 @@ coda_fbsd_clone(void *arg, struct ucred *cred, char *name, int namelen,
return;
if (dev_stdclone(name, NULL, "cfs", &u) != 1)
return;
*dev = make_dev(&codadevsw, unit2minor(u), UID_ROOT, GID_WHEEL, 0600,
*dev = make_dev(&codadevsw, u, UID_ROOT, GID_WHEEL, 0600,
"cfs%d", u);
dev_ref(*dev);
mnt = malloc(sizeof(struct coda_mntinfo), M_CODA, M_WAITOK|M_ZERO);

View File

@ -139,7 +139,7 @@ g_dev_taste(struct g_class *mp, struct g_provider *pp, int insist __unused)
KASSERT(error == 0,
("g_dev_taste(%s) failed to g_attach, err=%d", pp->name, error));
unit = alloc_unr(unithdr);
dev = make_dev(&g_dev_cdevsw, unit2minor(unit),
dev = make_dev(&g_dev_cdevsw, unit,
UID_ROOT, GID_OPERATOR, 0640, gp->name);
if (pp->flags & G_PF_CANDELETE)
dev->si_flags |= SI_CANDELETE;

View File

@ -235,10 +235,10 @@ apm_clone(void *arg, struct ucred *cred, char *name, int namelen,
unit = -1;
if (clone_create(&apm_clones, &apm_cdevsw, &unit, dev, 0)) {
if (ctl_dev) {
*dev = make_dev(&apm_cdevsw, unit2minor(unit),
*dev = make_dev(&apm_cdevsw, unit,
UID_ROOT, GID_OPERATOR, 0660, "apmctl%d", unit);
} else {
*dev = make_dev(&apm_cdevsw, unit2minor(unit),
*dev = make_dev(&apm_cdevsw, unit,
UID_ROOT, GID_OPERATOR, 0664, "apm%d", unit);
}
if (*dev != NULL) {

View File

@ -1017,7 +1017,7 @@ clone_create(struct clonedevs **cdp, struct cdevsw *csw, int *up, struct cdev **
}
if (unit == -1)
unit = low & CLONE_UNITMASK;
dev = newdev(csw, unit2minor(unit | extra), ndev);
dev = newdev(csw, unit | extra, ndev);
if (dev->si_flags & SI_CLONELIST) {
printf("dev %p (%s) is on clonelist\n", dev, dev->si_name);
printf("unit=%d, low=%d, extra=0x%x\n", unit, low, extra);

View File

@ -514,7 +514,7 @@ if_attach(struct ifnet *ifp)
#endif
ifdev_setbyindex(ifp->if_index, make_dev(&net_cdevsw,
unit2minor(ifp->if_index), UID_ROOT, GID_WHEEL, 0600, "%s/%s",
ifp->if_index, UID_ROOT, GID_WHEEL, 0600, "%s/%s",
net_cdevsw.d_name, ifp->if_xname));
make_dev_alias(ifdev_byindex(ifp->if_index), "%s%d",
net_cdevsw.d_name, ifp->if_index);

View File

@ -190,7 +190,7 @@ tap_clone_create(struct if_clone *ifc, int unit, caddr_t params)
/* find any existing device, or allocate new unit number */
i = clone_create(&tapclones, &tap_cdevsw, &unit, &dev, extra);
if (i) {
dev = make_dev(&tap_cdevsw, unit2minor(unit | extra),
dev = make_dev(&tap_cdevsw, unit | extra,
UID_ROOT, GID_WHEEL, 0600, "%s%d", ifc->ifc_name, unit);
if (dev != NULL) {
dev_ref(dev);
@ -381,7 +381,7 @@ tapclone(void *arg, struct ucred *cred, char *name, int namelen, struct cdev **d
name = devname;
}
*dev = make_dev(&tap_cdevsw, unit2minor(unit | extra),
*dev = make_dev(&tap_cdevsw, unit | extra,
UID_ROOT, GID_WHEEL, 0600, "%s", name);
if (*dev != NULL) {
dev_ref(*dev);

View File

@ -183,7 +183,7 @@ tun_clone_create(struct if_clone *ifc, int unit, caddr_t params)
i = clone_create(&tunclones, &tun_cdevsw, &unit, &dev, 0);
if (i) {
/* No preexisting struct cdev *, create one */
dev = make_dev(&tun_cdevsw, unit2minor(unit),
dev = make_dev(&tun_cdevsw, unit,
UID_UUCP, GID_DIALER, 0600, "%s%d", ifc->ifc_name, unit);
if (dev != NULL) {
dev_ref(dev);
@ -233,7 +233,7 @@ tunclone(void *arg, struct ucred *cred, char *name, int namelen,
name = devname;
}
/* No preexisting struct cdev *, create one */
*dev = make_dev(&tun_cdevsw, unit2minor(u),
*dev = make_dev(&tun_cdevsw, u,
UID_UUCP, GID_DIALER, 0600, "%s", name);
if (*dev != NULL) {
dev_ref(*dev);

View File

@ -179,7 +179,7 @@ ng_device_constructor(node_p node)
NG_NODE_SET_PRIVATE(node, priv);
priv->node = node;
priv->ngddev = make_dev(&ngd_cdevsw, unit2minor(priv->unit), UID_ROOT,
priv->ngddev = make_dev(&ngd_cdevsw, priv->unit, UID_ROOT,
GID_WHEEL, 0600, NG_DEVICE_DEVNAME "%d", priv->unit);
if(priv->ngddev == NULL) {
printf("%s(): make_dev() failed\n",__func__);

View File

@ -108,7 +108,7 @@ nsmb_dev_clone(void *arg, struct ucred *cred, char *name, int namelen,
return;
if (dev_stdclone(name, NULL, NSMB_NAME, &u) != 1)
return;
*dev = make_dev(&nsmb_cdevsw, unit2minor(u), 0, 0, 0600,
*dev = make_dev(&nsmb_cdevsw, u, 0, 0, 0600,
NSMB_NAME"%d", u);
dev_ref(*dev);
}

View File

@ -616,7 +616,7 @@ audit_pipe_clone(void *arg, struct ucred *cred, char *name, int namelen,
i = clone_create(&audit_pipe_clones, &audit_pipe_cdevsw, &u, dev, 0);
if (i) {
*dev = make_dev(&audit_pipe_cdevsw, unit2minor(u), UID_ROOT,
*dev = make_dev(&audit_pipe_cdevsw, u, UID_ROOT,
GID_WHEEL, 0600, "%s%d", AUDIT_PIPE_NAME, u);
if (*dev != NULL) {
dev_ref(*dev);