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:
parent
ed0c85e094
commit
d3ce832719
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=183381
@ -265,7 +265,7 @@ passregister(struct cam_periph *periph, void *arg)
|
|||||||
mtx_unlock(periph->sim->mtx);
|
mtx_unlock(periph->sim->mtx);
|
||||||
no_tags = (cgd->inq_data.flags & SID_CmdQue) == 0;
|
no_tags = (cgd->inq_data.flags & SID_CmdQue) == 0;
|
||||||
softc->device_stats = devstat_new_entry("pass",
|
softc->device_stats = devstat_new_entry("pass",
|
||||||
unit2minor(periph->unit_number), 0,
|
periph->unit_number, 0,
|
||||||
DEVSTAT_NO_BLOCKSIZE
|
DEVSTAT_NO_BLOCKSIZE
|
||||||
| (no_tags ? DEVSTAT_NO_ORDERED_TAGS : 0),
|
| (no_tags ? DEVSTAT_NO_ORDERED_TAGS : 0),
|
||||||
softc->pd_type |
|
softc->pd_type |
|
||||||
@ -274,7 +274,7 @@ passregister(struct cam_periph *periph, void *arg)
|
|||||||
DEVSTAT_PRIORITY_PASS);
|
DEVSTAT_PRIORITY_PASS);
|
||||||
|
|
||||||
/* Register the device */
|
/* 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",
|
UID_ROOT, GID_OPERATOR, 0600, "%s%d",
|
||||||
periph->periph_name, periph->unit_number);
|
periph->periph_name, periph->unit_number);
|
||||||
mtx_lock(periph->sim->mtx);
|
mtx_lock(periph->sim->mtx);
|
||||||
|
@ -343,7 +343,7 @@ sesregister(struct cam_periph *periph, void *arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
cam_periph_unlock(periph);
|
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",
|
UID_ROOT, GID_OPERATOR, 0600, "%s%d",
|
||||||
periph->periph_name, periph->unit_number);
|
periph->periph_name, periph->unit_number);
|
||||||
cam_periph_lock(periph);
|
cam_periph_lock(periph);
|
||||||
|
@ -287,7 +287,7 @@ sgregister(struct cam_periph *periph, void *arg)
|
|||||||
cam_periph_unlock(periph);
|
cam_periph_unlock(periph);
|
||||||
no_tags = (cgd->inq_data.flags & SID_CmdQue) == 0;
|
no_tags = (cgd->inq_data.flags & SID_CmdQue) == 0;
|
||||||
softc->device_stats = devstat_new_entry("sg",
|
softc->device_stats = devstat_new_entry("sg",
|
||||||
unit2minor(periph->unit_number), 0,
|
periph->unit_number, 0,
|
||||||
DEVSTAT_NO_BLOCKSIZE
|
DEVSTAT_NO_BLOCKSIZE
|
||||||
| (no_tags ? DEVSTAT_NO_ORDERED_TAGS : 0),
|
| (no_tags ? DEVSTAT_NO_ORDERED_TAGS : 0),
|
||||||
softc->pd_type |
|
softc->pd_type |
|
||||||
@ -296,7 +296,7 @@ sgregister(struct cam_periph *periph, void *arg)
|
|||||||
DEVSTAT_PRIORITY_PASS);
|
DEVSTAT_PRIORITY_PASS);
|
||||||
|
|
||||||
/* Register the device */
|
/* 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",
|
UID_ROOT, GID_OPERATOR, 0600, "%s%d",
|
||||||
periph->periph_name, periph->unit_number);
|
periph->periph_name, periph->unit_number);
|
||||||
(void)make_dev_alias(softc->dev, "sg%c", 'a' + periph->unit_number);
|
(void)make_dev_alias(softc->dev, "sg%c", 'a' + periph->unit_number);
|
||||||
|
@ -1031,7 +1031,7 @@ targclone(void *arg, struct ucred *cred, char *name, int namelen,
|
|||||||
return;
|
return;
|
||||||
if (dev_stdclone(name, NULL, "targ", &u) != 1)
|
if (dev_stdclone(name, NULL, "targ", &u) != 1)
|
||||||
return;
|
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);
|
0600, "targ%d", u);
|
||||||
dev_ref(*dev);
|
dev_ref(*dev);
|
||||||
(*dev)->si_flags |= SI_CHEAPCLONE;
|
(*dev)->si_flags |= SI_CHEAPCLONE;
|
||||||
|
@ -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. */
|
/* Clone the device to the new minor number. */
|
||||||
if (clone_create(&dtrace_clones, &dtrace_cdevsw, &u, dev, 0) != 0)
|
if (clone_create(&dtrace_clones, &dtrace_cdevsw, &u, dev, 0) != 0)
|
||||||
/* Create the /dev/dtrace/dtraceNN entry. */
|
/* 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);
|
UID_ROOT, GID_WHEEL, 0600, "dtrace/dtrace%d", u);
|
||||||
if (*dev != NULL) {
|
if (*dev != NULL) {
|
||||||
dev_ref(*dev);
|
dev_ref(*dev);
|
||||||
|
@ -257,7 +257,7 @@ led_create_state(led_t *func, void *priv, char const *name, int state)
|
|||||||
sc->unit = alloc_unr(led_unit);
|
sc->unit = alloc_unr(led_unit);
|
||||||
sc->private = priv;
|
sc->private = priv;
|
||||||
sc->func = func;
|
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);
|
UID_ROOT, GID_WHEEL, 0600, "led/%s", name);
|
||||||
sx_xunlock(&led_sx);
|
sx_xunlock(&led_sx);
|
||||||
|
|
||||||
|
@ -2313,7 +2313,7 @@ emu10kx_dev_init(struct emu_sc_info *sc)
|
|||||||
mtx_init(&sc->emu10kx_lock, device_get_nameunit(sc->dev), "kxdevlock", 0);
|
mtx_init(&sc->emu10kx_lock, device_get_nameunit(sc->dev), "kxdevlock", 0);
|
||||||
unit = device_get_unit(sc->dev);
|
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) {
|
if (sc->cdev != NULL) {
|
||||||
sc->cdev->si_drv1 = sc;
|
sc->cdev->si_drv1 = sc;
|
||||||
return (0);
|
return (0);
|
||||||
|
@ -2096,7 +2096,7 @@ dsp_clone(void *arg,
|
|||||||
snd_clone_setmaxunit(d->clones, tumax);
|
snd_clone_setmaxunit(d->clones, tumax);
|
||||||
if (ce != NULL) {
|
if (ce != NULL) {
|
||||||
udcmask |= snd_c2unit(cunit);
|
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",
|
UID_ROOT, GID_WHEEL, 0666, "%s%d%s%d",
|
||||||
devname, unit, devsep, cunit);
|
devname, unit, devsep, cunit);
|
||||||
snd_clone_register(ce, *dev);
|
snd_clone_register(ce, *dev);
|
||||||
|
@ -644,7 +644,7 @@ mixer_init(device_t dev, kobj_class_t cls, void *devinfo)
|
|||||||
|
|
||||||
unit = device_get_unit(dev);
|
unit = device_get_unit(dev);
|
||||||
devunit = snd_mkunit(unit, SND_DEV_CTL, 0);
|
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);
|
UID_ROOT, GID_WHEEL, 0666, "mixer%d", unit);
|
||||||
pdev->si_drv1 = m;
|
pdev->si_drv1 = m;
|
||||||
snddev = device_get_softc(dev);
|
snddev = device_get_softc(dev);
|
||||||
|
@ -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 */
|
/* find any existing device, or allocate new unit number */
|
||||||
if (clone_create(&vkbd_dev_clones, &vkbd_dev_cdevsw, &unit, dev, 0)) {
|
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);
|
UID_ROOT, GID_WHEEL, 0600, DEVICE_NAME "%d", unit);
|
||||||
if (*dev != NULL) {
|
if (*dev != NULL) {
|
||||||
dev_ref(*dev);
|
dev_ref(*dev);
|
||||||
|
@ -127,7 +127,7 @@ coda_fbsd_clone(void *arg, struct ucred *cred, char *name, int namelen,
|
|||||||
return;
|
return;
|
||||||
if (dev_stdclone(name, NULL, "cfs", &u) != 1)
|
if (dev_stdclone(name, NULL, "cfs", &u) != 1)
|
||||||
return;
|
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);
|
"cfs%d", u);
|
||||||
dev_ref(*dev);
|
dev_ref(*dev);
|
||||||
mnt = malloc(sizeof(struct coda_mntinfo), M_CODA, M_WAITOK|M_ZERO);
|
mnt = malloc(sizeof(struct coda_mntinfo), M_CODA, M_WAITOK|M_ZERO);
|
||||||
|
@ -139,7 +139,7 @@ g_dev_taste(struct g_class *mp, struct g_provider *pp, int insist __unused)
|
|||||||
KASSERT(error == 0,
|
KASSERT(error == 0,
|
||||||
("g_dev_taste(%s) failed to g_attach, err=%d", pp->name, error));
|
("g_dev_taste(%s) failed to g_attach, err=%d", pp->name, error));
|
||||||
unit = alloc_unr(unithdr);
|
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);
|
UID_ROOT, GID_OPERATOR, 0640, gp->name);
|
||||||
if (pp->flags & G_PF_CANDELETE)
|
if (pp->flags & G_PF_CANDELETE)
|
||||||
dev->si_flags |= SI_CANDELETE;
|
dev->si_flags |= SI_CANDELETE;
|
||||||
|
@ -235,10 +235,10 @@ apm_clone(void *arg, struct ucred *cred, char *name, int namelen,
|
|||||||
unit = -1;
|
unit = -1;
|
||||||
if (clone_create(&apm_clones, &apm_cdevsw, &unit, dev, 0)) {
|
if (clone_create(&apm_clones, &apm_cdevsw, &unit, dev, 0)) {
|
||||||
if (ctl_dev) {
|
if (ctl_dev) {
|
||||||
*dev = make_dev(&apm_cdevsw, unit2minor(unit),
|
*dev = make_dev(&apm_cdevsw, unit,
|
||||||
UID_ROOT, GID_OPERATOR, 0660, "apmctl%d", unit);
|
UID_ROOT, GID_OPERATOR, 0660, "apmctl%d", unit);
|
||||||
} else {
|
} else {
|
||||||
*dev = make_dev(&apm_cdevsw, unit2minor(unit),
|
*dev = make_dev(&apm_cdevsw, unit,
|
||||||
UID_ROOT, GID_OPERATOR, 0664, "apm%d", unit);
|
UID_ROOT, GID_OPERATOR, 0664, "apm%d", unit);
|
||||||
}
|
}
|
||||||
if (*dev != NULL) {
|
if (*dev != NULL) {
|
||||||
|
@ -1017,7 +1017,7 @@ clone_create(struct clonedevs **cdp, struct cdevsw *csw, int *up, struct cdev **
|
|||||||
}
|
}
|
||||||
if (unit == -1)
|
if (unit == -1)
|
||||||
unit = low & CLONE_UNITMASK;
|
unit = low & CLONE_UNITMASK;
|
||||||
dev = newdev(csw, unit2minor(unit | extra), ndev);
|
dev = newdev(csw, unit | extra, ndev);
|
||||||
if (dev->si_flags & SI_CLONELIST) {
|
if (dev->si_flags & SI_CLONELIST) {
|
||||||
printf("dev %p (%s) is on clonelist\n", dev, dev->si_name);
|
printf("dev %p (%s) is on clonelist\n", dev, dev->si_name);
|
||||||
printf("unit=%d, low=%d, extra=0x%x\n", unit, low, extra);
|
printf("unit=%d, low=%d, extra=0x%x\n", unit, low, extra);
|
||||||
|
@ -514,7 +514,7 @@ if_attach(struct ifnet *ifp)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
ifdev_setbyindex(ifp->if_index, make_dev(&net_cdevsw,
|
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));
|
net_cdevsw.d_name, ifp->if_xname));
|
||||||
make_dev_alias(ifdev_byindex(ifp->if_index), "%s%d",
|
make_dev_alias(ifdev_byindex(ifp->if_index), "%s%d",
|
||||||
net_cdevsw.d_name, ifp->if_index);
|
net_cdevsw.d_name, ifp->if_index);
|
||||||
|
@ -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 */
|
/* find any existing device, or allocate new unit number */
|
||||||
i = clone_create(&tapclones, &tap_cdevsw, &unit, &dev, extra);
|
i = clone_create(&tapclones, &tap_cdevsw, &unit, &dev, extra);
|
||||||
if (i) {
|
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);
|
UID_ROOT, GID_WHEEL, 0600, "%s%d", ifc->ifc_name, unit);
|
||||||
if (dev != NULL) {
|
if (dev != NULL) {
|
||||||
dev_ref(dev);
|
dev_ref(dev);
|
||||||
@ -381,7 +381,7 @@ tapclone(void *arg, struct ucred *cred, char *name, int namelen, struct cdev **d
|
|||||||
name = devname;
|
name = devname;
|
||||||
}
|
}
|
||||||
|
|
||||||
*dev = make_dev(&tap_cdevsw, unit2minor(unit | extra),
|
*dev = make_dev(&tap_cdevsw, unit | extra,
|
||||||
UID_ROOT, GID_WHEEL, 0600, "%s", name);
|
UID_ROOT, GID_WHEEL, 0600, "%s", name);
|
||||||
if (*dev != NULL) {
|
if (*dev != NULL) {
|
||||||
dev_ref(*dev);
|
dev_ref(*dev);
|
||||||
|
@ -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);
|
i = clone_create(&tunclones, &tun_cdevsw, &unit, &dev, 0);
|
||||||
if (i) {
|
if (i) {
|
||||||
/* No preexisting struct cdev *, create one */
|
/* 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);
|
UID_UUCP, GID_DIALER, 0600, "%s%d", ifc->ifc_name, unit);
|
||||||
if (dev != NULL) {
|
if (dev != NULL) {
|
||||||
dev_ref(dev);
|
dev_ref(dev);
|
||||||
@ -233,7 +233,7 @@ tunclone(void *arg, struct ucred *cred, char *name, int namelen,
|
|||||||
name = devname;
|
name = devname;
|
||||||
}
|
}
|
||||||
/* No preexisting struct cdev *, create one */
|
/* 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);
|
UID_UUCP, GID_DIALER, 0600, "%s", name);
|
||||||
if (*dev != NULL) {
|
if (*dev != NULL) {
|
||||||
dev_ref(*dev);
|
dev_ref(*dev);
|
||||||
|
@ -179,7 +179,7 @@ ng_device_constructor(node_p node)
|
|||||||
NG_NODE_SET_PRIVATE(node, priv);
|
NG_NODE_SET_PRIVATE(node, priv);
|
||||||
priv->node = node;
|
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);
|
GID_WHEEL, 0600, NG_DEVICE_DEVNAME "%d", priv->unit);
|
||||||
if(priv->ngddev == NULL) {
|
if(priv->ngddev == NULL) {
|
||||||
printf("%s(): make_dev() failed\n",__func__);
|
printf("%s(): make_dev() failed\n",__func__);
|
||||||
|
@ -108,7 +108,7 @@ nsmb_dev_clone(void *arg, struct ucred *cred, char *name, int namelen,
|
|||||||
return;
|
return;
|
||||||
if (dev_stdclone(name, NULL, NSMB_NAME, &u) != 1)
|
if (dev_stdclone(name, NULL, NSMB_NAME, &u) != 1)
|
||||||
return;
|
return;
|
||||||
*dev = make_dev(&nsmb_cdevsw, unit2minor(u), 0, 0, 0600,
|
*dev = make_dev(&nsmb_cdevsw, u, 0, 0, 0600,
|
||||||
NSMB_NAME"%d", u);
|
NSMB_NAME"%d", u);
|
||||||
dev_ref(*dev);
|
dev_ref(*dev);
|
||||||
}
|
}
|
||||||
|
@ -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);
|
i = clone_create(&audit_pipe_clones, &audit_pipe_cdevsw, &u, dev, 0);
|
||||||
if (i) {
|
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);
|
GID_WHEEL, 0600, "%s%d", AUDIT_PIPE_NAME, u);
|
||||||
if (*dev != NULL) {
|
if (*dev != NULL) {
|
||||||
dev_ref(*dev);
|
dev_ref(*dev);
|
||||||
|
Loading…
Reference in New Issue
Block a user