From d3ce8327194c0bcf742f2e03b5b0dc8f8cfe7f6b Mon Sep 17 00:00:00 2001 From: Ed Schouten Date: Fri, 26 Sep 2008 14:19:52 +0000 Subject: [PATCH] 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 --- sys/cam/scsi/scsi_pass.c | 4 ++-- sys/cam/scsi/scsi_ses.c | 2 +- sys/cam/scsi/scsi_sg.c | 4 ++-- sys/cam/scsi/scsi_target.c | 2 +- sys/cddl/dev/dtrace/dtrace_clone.c | 2 +- sys/dev/led/led.c | 2 +- sys/dev/sound/pci/emu10kx.c | 2 +- sys/dev/sound/pcm/dsp.c | 2 +- sys/dev/sound/pcm/mixer.c | 2 +- sys/dev/vkbd/vkbd.c | 2 +- sys/fs/coda/coda_fbsd.c | 2 +- sys/geom/geom_dev.c | 2 +- sys/i386/acpica/acpi_machdep.c | 4 ++-- sys/kern/kern_conf.c | 2 +- sys/net/if.c | 2 +- sys/net/if_tap.c | 4 ++-- sys/net/if_tun.c | 4 ++-- sys/netgraph/ng_device.c | 2 +- sys/netsmb/smb_dev.c | 2 +- sys/security/audit/audit_pipe.c | 2 +- 20 files changed, 25 insertions(+), 25 deletions(-) diff --git a/sys/cam/scsi/scsi_pass.c b/sys/cam/scsi/scsi_pass.c index 17084e6f8d71..1f5f08922887 100644 --- a/sys/cam/scsi/scsi_pass.c +++ b/sys/cam/scsi/scsi_pass.c @@ -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); diff --git a/sys/cam/scsi/scsi_ses.c b/sys/cam/scsi/scsi_ses.c index 67f3bdcd49f6..efccf09d2965 100644 --- a/sys/cam/scsi/scsi_ses.c +++ b/sys/cam/scsi/scsi_ses.c @@ -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); diff --git a/sys/cam/scsi/scsi_sg.c b/sys/cam/scsi/scsi_sg.c index f636c7d25e52..af2ab6e92b74 100644 --- a/sys/cam/scsi/scsi_sg.c +++ b/sys/cam/scsi/scsi_sg.c @@ -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); diff --git a/sys/cam/scsi/scsi_target.c b/sys/cam/scsi/scsi_target.c index c6086f948eac..140da9b422f4 100644 --- a/sys/cam/scsi/scsi_target.c +++ b/sys/cam/scsi/scsi_target.c @@ -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; diff --git a/sys/cddl/dev/dtrace/dtrace_clone.c b/sys/cddl/dev/dtrace/dtrace_clone.c index 52e48ff1bd79..be1e3d41ac99 100644 --- a/sys/cddl/dev/dtrace/dtrace_clone.c +++ b/sys/cddl/dev/dtrace/dtrace_clone.c @@ -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); diff --git a/sys/dev/led/led.c b/sys/dev/led/led.c index d086f4e5e38e..1d902d56aa75 100644 --- a/sys/dev/led/led.c +++ b/sys/dev/led/led.c @@ -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); diff --git a/sys/dev/sound/pci/emu10kx.c b/sys/dev/sound/pci/emu10kx.c index c2a8249ca5c7..76f7e60757a2 100644 --- a/sys/dev/sound/pci/emu10kx.c +++ b/sys/dev/sound/pci/emu10kx.c @@ -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); diff --git a/sys/dev/sound/pcm/dsp.c b/sys/dev/sound/pcm/dsp.c index f718975c2034..f13ae319231d 100644 --- a/sys/dev/sound/pcm/dsp.c +++ b/sys/dev/sound/pcm/dsp.c @@ -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); diff --git a/sys/dev/sound/pcm/mixer.c b/sys/dev/sound/pcm/mixer.c index 6196817e9b26..c3ca4f0dea47 100644 --- a/sys/dev/sound/pcm/mixer.c +++ b/sys/dev/sound/pcm/mixer.c @@ -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); diff --git a/sys/dev/vkbd/vkbd.c b/sys/dev/vkbd/vkbd.c index 10e35160f364..15cf05934f0b 100644 --- a/sys/dev/vkbd/vkbd.c +++ b/sys/dev/vkbd/vkbd.c @@ -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); diff --git a/sys/fs/coda/coda_fbsd.c b/sys/fs/coda/coda_fbsd.c index 765c3fd9a290..62d085723aa7 100644 --- a/sys/fs/coda/coda_fbsd.c +++ b/sys/fs/coda/coda_fbsd.c @@ -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); diff --git a/sys/geom/geom_dev.c b/sys/geom/geom_dev.c index eeb3b0932a48..8bf698166051 100644 --- a/sys/geom/geom_dev.c +++ b/sys/geom/geom_dev.c @@ -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; diff --git a/sys/i386/acpica/acpi_machdep.c b/sys/i386/acpica/acpi_machdep.c index 9d24e62954fd..8d130fbe668e 100644 --- a/sys/i386/acpica/acpi_machdep.c +++ b/sys/i386/acpica/acpi_machdep.c @@ -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) { diff --git a/sys/kern/kern_conf.c b/sys/kern/kern_conf.c index 409652f75310..c276c8783527 100644 --- a/sys/kern/kern_conf.c +++ b/sys/kern/kern_conf.c @@ -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); diff --git a/sys/net/if.c b/sys/net/if.c index 11df9793949c..0bc03299a947 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -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); diff --git a/sys/net/if_tap.c b/sys/net/if_tap.c index 0e0b25c06eed..25728f4d018c 100644 --- a/sys/net/if_tap.c +++ b/sys/net/if_tap.c @@ -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); diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c index 6f6f05ca6da0..24f31874d362 100644 --- a/sys/net/if_tun.c +++ b/sys/net/if_tun.c @@ -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); diff --git a/sys/netgraph/ng_device.c b/sys/netgraph/ng_device.c index d8ba67650ed1..5db921881af3 100644 --- a/sys/netgraph/ng_device.c +++ b/sys/netgraph/ng_device.c @@ -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__); diff --git a/sys/netsmb/smb_dev.c b/sys/netsmb/smb_dev.c index 3181438b4657..c77297eec409 100644 --- a/sys/netsmb/smb_dev.c +++ b/sys/netsmb/smb_dev.c @@ -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); } diff --git a/sys/security/audit/audit_pipe.c b/sys/security/audit/audit_pipe.c index 00b09cab68c1..4b9621badb7c 100644 --- a/sys/security/audit/audit_pipe.c +++ b/sys/security/audit/audit_pipe.c @@ -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);