Device megapatch 5/6:
Remove the unused second argument from udev2dev(). Convert all remaining users of makedev() to use udev2dev(). The semantic difference is that udev2dev() will only locate a pre-existing dev_t, it will not line makedev() create a new one. Apart from the tiny well controlled windown in D_PSEUDO drivers, there should no longer be any "anonymous" dev_t's in the system now, only dev_t's created with make_dev() and make_dev_alias()
This commit is contained in:
parent
dc08ffec87
commit
816d62bbb9
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=126081
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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) {
|
||||
|
@ -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
|
||||
|
@ -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));
|
||||
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user