diff --git a/sys/coda/coda_venus.c b/sys/coda/coda_venus.c index 8067226b7777..5105c0b882bc 100644 --- a/sys/coda/coda_venus.c +++ b/sys/coda/coda_venus.c @@ -212,8 +212,7 @@ venus_open(void *mdp, CodaFid *fid, int flag, error = coda_call(mdp, Isize, &Osize, (char *)inp); if (!error) { -/* 5/11 *dev = udev2dev(outp->dev, 2); */ - *dev = udev2dev(outp->dev, 0); + *dev = udev2dev(outp->dev); *inode = outp->inode; } diff --git a/sys/compat/linux/linux_stats.c b/sys/compat/linux/linux_stats.c index ec6e0677047e..9d61de2064b9 100644 --- a/sys/compat/linux/linux_stats.c +++ b/sys/compat/linux/linux_stats.c @@ -76,7 +76,7 @@ newstat_copyout(struct stat *buf, void *ubuf) * in FreeBSD but block devices under Linux. */ if (S_ISCHR(tbuf.st_mode) && - (dev = udev2dev(buf->st_rdev, 0)) != NODEV) { + (dev = udev2dev(buf->st_rdev)) != NODEV) { cdevsw = devsw(dev); if (cdevsw != NULL && (cdevsw->d_flags & D_DISK)) { tbuf.st_mode &= ~S_IFMT; @@ -365,8 +365,8 @@ linux_ustat(struct thread *td, struct linux_ustat_args *args) * dev_t returned from previous syscalls. Just return a bzeroed * ustat in that case. */ - dev = makedev(args->dev >> 8, args->dev & 0xFF); - if (vfinddev(dev, VCHR, &vp)) { + dev = udev2dev(makeudev(args->dev >> 8, args->dev & 0xFF)); + if (dev != NODEV && vfinddev(dev, VCHR, &vp)) { if (vp->v_mount == NULL) return (EINVAL); #ifdef MAC @@ -414,7 +414,7 @@ stat64_copyout(struct stat *buf, void *ubuf) * in FreeBSD but block devices under Linux. */ if (S_ISCHR(lbuf.st_mode) && - (dev = udev2dev(buf->st_rdev, 0)) != NODEV) { + (dev = udev2dev(buf->st_rdev)) != NODEV) { cdevsw = devsw(dev); if (cdevsw != NULL && (cdevsw->d_flags & D_DISK)) { lbuf.st_mode &= ~S_IFMT; diff --git a/sys/dev/cx/if_cx.c b/sys/dev/cx/if_cx.c index 842348eb1f72..9a3acc28071f 100644 --- a/sys/dev/cx/if_cx.c +++ b/sys/dev/cx/if_cx.c @@ -3105,7 +3105,7 @@ static int cx_modevent (module_t mod, int type, void *unused) static int load_count = 0; struct cdevsw *cdsw; - dev = makedev (CDEV_MAJOR, 0); + dev = udev2dev (makeudev(CDEV_MAJOR, 0)); switch (type) { case MOD_LOAD: if ((cdsw = devsw (dev)) && cdsw->d_maj == CDEV_MAJOR) { diff --git a/sys/dev/raidframe/rf_freebsdkintf.c b/sys/dev/raidframe/rf_freebsdkintf.c index 0dfc43623e01..585fad7bc2a4 100644 --- a/sys/dev/raidframe/rf_freebsdkintf.c +++ b/sys/dev/raidframe/rf_freebsdkintf.c @@ -3144,8 +3144,8 @@ raid_getcomponentsize(RF_Raid_t *raidPtr, RF_RowCol_t row, RF_RowCol_t col) raidPtr->Disks[row][col].numBlocks = mediasize / secsize; raidPtr->raid_cinfo[row][col].ci_vp = vp; - raidPtr->raid_cinfo[row][col].ci_dev = udev2dev(va.va_rdev, 0); - raidPtr->Disks[row][col].dev = udev2dev(va.va_rdev, 0); + raidPtr->raid_cinfo[row][col].ci_dev = udev2dev(va.va_rdev); + raidPtr->Disks[row][col].dev = udev2dev(va.va_rdev); /* we allow the user to specify that only a fraction of the disks should be used this is diff --git a/sys/dev/snp/snp.c b/sys/dev/snp/snp.c index 543a7242b2b4..6e4eb9ab710c 100644 --- a/sys/dev/snp/snp.c +++ b/sys/dev/snp/snp.c @@ -500,7 +500,7 @@ snpioctl(dev, cmd, data, flags, td) snp = dev->si_drv1; switch (cmd) { case SNPSTTY: - tdev = udev2dev(*((udev_t *)data), 0); + tdev = udev2dev(*((udev_t *)data)); if (tdev == NODEV) return (snp_down(snp)); diff --git a/sys/dev/sound/midi/midi.h b/sys/dev/sound/midi/midi.h index 9ba9c952366f..634d457f5c53 100644 --- a/sys/dev/sound/midi/midi.h +++ b/sys/dev/sound/midi/midi.h @@ -259,7 +259,7 @@ struct _mididev_info { #define MIDIUNIT(x) ((MIDIMINOR(x) & 0x000000f0) >> 4) #define MIDIDEV(x) (MIDIMINOR(x) & 0x0000000f) #define MIDIMKMINOR(u, d) (((u) & 0x0f) << 4 | ((d) & 0x0f)) -#define MIDIMKDEV(m, u, d) (makedev((m), MIDIMKMINOR((u), (d)))) +#define MIDIMKDEV(m, u, d) (udev2dev(makeudev((m), MIDIMKMINOR((u), (d))))) /* * see if the device is configured diff --git a/sys/fs/coda/coda_venus.c b/sys/fs/coda/coda_venus.c index 8067226b7777..5105c0b882bc 100644 --- a/sys/fs/coda/coda_venus.c +++ b/sys/fs/coda/coda_venus.c @@ -212,8 +212,7 @@ venus_open(void *mdp, CodaFid *fid, int flag, error = coda_call(mdp, Isize, &Osize, (char *)inp); if (!error) { -/* 5/11 *dev = udev2dev(outp->dev, 2); */ - *dev = udev2dev(outp->dev, 0); + *dev = udev2dev(outp->dev); *inode = outp->inode; } diff --git a/sys/kern/kern_conf.c b/sys/kern/kern_conf.c index 85f5ba27ec42..bedbd1e48d41 100644 --- a/sys/kern/kern_conf.c +++ b/sys/kern/kern_conf.c @@ -68,6 +68,8 @@ static LIST_HEAD(, cdev) dev_free; static int free_devt; SYSCTL_INT(_debug, OID_AUTO, free_devt, CTLFLAG_RW, &free_devt, 0, ""); +static dev_t makedev(int x, int y); + int nullop(void) { @@ -244,7 +246,7 @@ allocdev(void) return (si); } -dev_t +static dev_t makedev(int x, int y) { struct cdev *si; @@ -294,18 +296,19 @@ dev2udev(dev_t x) } dev_t -udev2dev(udev_t x, int b) +udev2dev(udev_t udev) { + struct cdev *si; + int hash; - if (x == NOUDEV) - return (NODEV); - switch (b) { - case 0: - return (makedev(umajor(x), uminor(x))); - default: - Debugger("udev2dev(...,X)"); + if (udev == NOUDEV) return (NODEV); + hash = udev % DEVT_HASH; + LIST_FOREACH(si, &dev_hash[hash], si_hash) { + if (si->si_udev == udev) + return (si); } + return (NODEV); } int diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index dc670d6d6c55..bcf7af869400 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -1807,7 +1807,7 @@ addaliasu(nvp, nvp_rdev) return (nvp); if (nvp->v_type != VCHR) panic("addaliasu on non-special vnode"); - dev = udev2dev(nvp_rdev, 0); + dev = udev2dev(nvp_rdev); /* * Check to see if we have a bdevvp vnode with no associated * filesystem. If so, we want to associate the filesystem of diff --git a/sys/sys/systm.h b/sys/sys/systm.h index 8e02a0a38091..71c4021fa81f 100644 --- a/sys/sys/systm.h +++ b/sys/sys/systm.h @@ -323,9 +323,8 @@ void wakeup_one(void *chan) __nonnull(1); int major(dev_t x); int minor(dev_t x); -dev_t makedev(int x, int y); udev_t dev2udev(dev_t x); -dev_t udev2dev(udev_t x, int b); +dev_t udev2dev(udev_t x); int uminor(udev_t dev); int umajor(udev_t dev); udev_t makeudev(int x, int y);