Turn dev2unit(), minor(), unit2minor() and minor2unit() into macro's.
Now that we got rid of the minor-to-unit conversion and the constraints on device minor numbers, we can convert the functions that operate on minor and unit numbers to simple macro's. The unit2minor() and minor2unit() macro's are now no-ops. The ZFS code als defined a macro named `minor'. Change the ZFS code to use umajor() and uminor() here, as it is the correct approach to do this. Also add $FreeBSD$ to keep SVN happy. Approved by: philip (mentor), pjd
This commit is contained in:
parent
9a764aac3f
commit
0f03ce1bb8
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=179757
@ -17,6 +17,8 @@
|
||||
* information: Portions Copyright [yyyy] [name of copyright owner]
|
||||
*
|
||||
* CDDL HEADER END
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
/*
|
||||
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
|
||||
@ -279,12 +281,6 @@ zfs_init_fs(zfsvfs_t *zfsvfs, znode_t **zpp, cred_t *cr)
|
||||
#ifndef MAXMIN64
|
||||
#define MAXMIN64 0xffffffffUL
|
||||
#endif
|
||||
#ifndef major
|
||||
#define major(x) ((int)(((u_int)(x) >> 8)&0xff)) /* major number */
|
||||
#endif
|
||||
#ifndef minor
|
||||
#define minor(x) ((int)((x)&0xffff00ff)) /* minor number */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Create special expldev for ZFS private use.
|
||||
@ -297,7 +293,7 @@ zfs_init_fs(zfsvfs_t *zfsvfs, znode_t **zpp, cred_t *cr)
|
||||
static uint64_t
|
||||
zfs_expldev(dev_t dev)
|
||||
{
|
||||
return (((uint64_t)major(dev) << NBITSMINOR64) | minor(dev));
|
||||
return (((uint64_t)umajor(dev) << NBITSMINOR64) | uminor(dev));
|
||||
}
|
||||
/*
|
||||
* Special cmpldev for ZFS private use.
|
||||
|
@ -492,41 +492,6 @@ giant_mmap(struct cdev *dev, vm_offset_t offset, vm_paddr_t *paddr, int nprot)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* struct cdev * and u_dev_t primitives
|
||||
*/
|
||||
|
||||
int
|
||||
minor(struct cdev *x)
|
||||
{
|
||||
if (x == NULL)
|
||||
return NODEV;
|
||||
return (x->si_drv0);
|
||||
}
|
||||
|
||||
int
|
||||
dev2unit(struct cdev *x)
|
||||
{
|
||||
|
||||
if (x == NULL)
|
||||
return NODEV;
|
||||
return (x->si_drv0);
|
||||
}
|
||||
|
||||
u_int
|
||||
minor2unit(u_int _minor)
|
||||
{
|
||||
|
||||
return (_minor);
|
||||
}
|
||||
|
||||
int
|
||||
unit2minor(int unit)
|
||||
{
|
||||
|
||||
return (unit);
|
||||
}
|
||||
|
||||
static void
|
||||
notify(struct cdev *dev, const char *ev)
|
||||
{
|
||||
|
@ -273,13 +273,15 @@ struct cdev *make_dev_credf(int _flags,
|
||||
struct ucred *_cr, uid_t _uid, gid_t _gid, int _mode,
|
||||
const char *_fmt, ...) __printflike(8, 9);
|
||||
struct cdev *make_dev_alias(struct cdev *_pdev, const char *_fmt, ...) __printflike(2, 3);
|
||||
int dev2unit(struct cdev *_dev);
|
||||
void dev_lock(void);
|
||||
void dev_unlock(void);
|
||||
int unit2minor(int _unit);
|
||||
u_int minor2unit(u_int _minor);
|
||||
void setconf(void);
|
||||
|
||||
#define dev2unit(d) ((d) ? (d)->si_drv0 : NODEV)
|
||||
#define minor(d) ((d) ? (d)->si_drv0 : NODEV)
|
||||
#define unit2minor(u) (u)
|
||||
#define minor2unit(m) (m)
|
||||
|
||||
typedef void (*cdevpriv_dtr_t)(void *data);
|
||||
int devfs_get_cdevpriv(void **datap);
|
||||
int devfs_set_cdevpriv(void *priv, cdevpriv_dtr_t dtr);
|
||||
|
@ -311,7 +311,6 @@ void wakeup_one(void *chan) __nonnull(1);
|
||||
*/
|
||||
|
||||
struct cdev;
|
||||
int minor(struct cdev *x);
|
||||
dev_t dev2udev(struct cdev *x);
|
||||
int uminor(dev_t dev);
|
||||
int umajor(dev_t dev);
|
||||
|
Loading…
Reference in New Issue
Block a user