summaryrefslogtreecommitdiffstats
path: root/sys/fs/devfs
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2008-06-16 17:34:59 +0000
committerkib <kib@FreeBSD.org>2008-06-16 17:34:59 +0000
commiteecc60305f3565e1e1bb12659d2fec4ea09ebbf1 (patch)
tree8e320b542868d0439ab549cd9da52c45bb24aabf /sys/fs/devfs
parent4c48f0aa48a663c0fbd8b13ab1334deff50098f0 (diff)
downloadFreeBSD-src-eecc60305f3565e1e1bb12659d2fec4ea09ebbf1.zip
FreeBSD-src-eecc60305f3565e1e1bb12659d2fec4ea09ebbf1.tar.gz
Struct cdev is always the member of the struct cdev_priv. When devfs
needed to promote cdev to cdev_priv, the si_priv pointer was followed. Use member2struct() to calculate address of the wrapping cdev_priv. Rename si_priv to __si_reserved. Tested by: pho Reviewed by: ed MFC after: 2 weeks
Diffstat (limited to 'sys/fs/devfs')
-rw-r--r--sys/fs/devfs/devfs_devs.c7
-rw-r--r--sys/fs/devfs/devfs_int.h2
-rw-r--r--sys/fs/devfs/devfs_vnops.c10
3 files changed, 10 insertions, 9 deletions
diff --git a/sys/fs/devfs/devfs_devs.c b/sys/fs/devfs/devfs_devs.c
index 1d5e3c9..45f8d58 100644
--- a/sys/fs/devfs/devfs_devs.c
+++ b/sys/fs/devfs/devfs_devs.c
@@ -125,7 +125,6 @@ devfs_alloc(void)
cdp->cdp_maxdirent = 0;
cdev = &cdp->cdp_c;
- cdev->si_priv = cdp;
cdev->si_name = cdev->__si_namebuf;
LIST_INIT(&cdev->si_children);
@@ -137,7 +136,7 @@ devfs_free(struct cdev *cdev)
{
struct cdev_priv *cdp;
- cdp = cdev->si_priv;
+ cdp = cdev2priv(cdev);
if (cdev->si_cred != NULL)
crfree(cdev->si_cred);
if (cdp->cdp_inode > 0)
@@ -510,7 +509,7 @@ devfs_create(struct cdev *dev)
struct cdev_priv *cdp;
mtx_assert(&devmtx, MA_OWNED);
- cdp = dev->si_priv;
+ cdp = cdev2priv(dev);
cdp->cdp_flags |= CDP_ACTIVE;
cdp->cdp_inode = alloc_unrl(devfs_inos);
dev_refl(dev);
@@ -524,7 +523,7 @@ devfs_destroy(struct cdev *dev)
struct cdev_priv *cdp;
mtx_assert(&devmtx, MA_OWNED);
- cdp = dev->si_priv;
+ cdp = cdev2priv(dev);
cdp->cdp_flags &= ~CDP_ACTIVE;
devfs_generation++;
}
diff --git a/sys/fs/devfs/devfs_int.h b/sys/fs/devfs/devfs_int.h
index df0ad56..5a61dd4 100644
--- a/sys/fs/devfs/devfs_int.h
+++ b/sys/fs/devfs/devfs_int.h
@@ -68,6 +68,8 @@ struct cdev_priv {
LIST_HEAD(, cdev_privdata) cdp_fdpriv;
};
+#define cdev2priv(c) member2struct(cdev_priv, cdp_c, c)
+
struct cdev *devfs_alloc(void);
void devfs_free(struct cdev *);
void devfs_create(struct cdev *dev);
diff --git a/sys/fs/devfs/devfs_vnops.c b/sys/fs/devfs/devfs_vnops.c
index 649f492d..8130642 100644
--- a/sys/fs/devfs/devfs_vnops.c
+++ b/sys/fs/devfs/devfs_vnops.c
@@ -132,7 +132,7 @@ devfs_set_cdevpriv(void *priv, cdevpriv_dtr_t priv_dtr)
fp = curthread->td_fpop;
if (fp == NULL)
return (ENOENT);
- cdp = ((struct cdev *)fp->f_data)->si_priv;
+ cdp = cdev2priv((struct cdev *)fp->f_data);
p = malloc(sizeof(struct cdev_privdata), M_CDEVPDATA, M_WAITOK);
p->cdpd_data = priv;
p->cdpd_dtr = priv_dtr;
@@ -541,7 +541,7 @@ devfs_getattr(struct vop_getattr_args *ap)
fix(dev->si_ctime);
vap->va_ctime = dev->si_ctime;
- vap->va_rdev = dev->si_priv->cdp_inode;
+ vap->va_rdev = cdev2priv(dev)->cdp_inode;
}
vap->va_gen = 0;
vap->va_flags = 0;
@@ -742,7 +742,7 @@ devfs_lookupx(struct vop_lookup_args *ap, int *dm_unlock)
}
dev_lock();
- dde = &cdev->si_priv->cdp_dirents[dmp->dm_idx];
+ dde = &cdev2priv(cdev)->cdp_dirents[dmp->dm_idx];
if (dde != NULL && *dde != NULL)
de = *dde;
dev_unlock();
@@ -1141,7 +1141,7 @@ devfs_revoke(struct vop_revoke_args *ap)
KASSERT((ap->a_flags & REVOKEALL) != 0, ("devfs_revoke !REVOKEALL"));
dev = vp->v_rdev;
- cdp = dev->si_priv;
+ cdp = cdev2priv(dev);
dev_lock();
cdp->cdp_inuse++;
@@ -1419,7 +1419,7 @@ dev2udev(struct cdev *x)
{
if (x == NULL)
return (NODEV);
- return (x->si_priv->cdp_inode);
+ return (cdev2priv(x)->cdp_inode);
}
static struct fileops devfs_ops_f = {
OpenPOWER on IntegriCloud