summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_conf.c
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2004-09-24 05:54:32 +0000
committerphk <phk@FreeBSD.org>2004-09-24 05:54:32 +0000
commit7ede6d888ce643e68a37e09f8499ef2555a38c4e (patch)
tree683fd338017646edb876f7df0caa766fc6bfac2b /sys/kern/kern_conf.c
parentcdf79b2b3708519ec4e09e6837ba6f369960ad03 (diff)
downloadFreeBSD-src-7ede6d888ce643e68a37e09f8499ef2555a38c4e.zip
FreeBSD-src-7ede6d888ce643e68a37e09f8499ef2555a38c4e.tar.gz
Introduce dev_re[lf]thread() functions.
dev_refthread() will return the cdevsw pointer or NULL. If the return value is non-NULL a threadcount is held which much be released with dev_relthread(). If the returned cdevsw is NULL no threadcount is held on the device.
Diffstat (limited to 'sys/kern/kern_conf.c')
-rw-r--r--sys/kern/kern_conf.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/sys/kern/kern_conf.c b/sys/kern/kern_conf.c
index 46fca85..e3e9495 100644
--- a/sys/kern/kern_conf.c
+++ b/sys/kern/kern_conf.c
@@ -84,12 +84,14 @@ dev_lock(void)
void
dev_unlock(void)
{
+
mtx_unlock(&devmtx);
}
void
dev_ref(struct cdev *dev)
{
+
dev_lock();
dev->si_refcount++;
dev_unlock();
@@ -107,6 +109,29 @@ dev_rel(struct cdev *dev)
freedev(dev);
}
}
+struct cdevsw *
+dev_refthread(struct cdev *dev)
+{
+ struct cdevsw *csw;
+
+ mtx_assert(&devmtx, MA_NOTOWNED);
+ dev_lock();
+ csw = dev->si_devsw;
+ if (csw != NULL)
+ dev->si_threadcount++;
+ dev_unlock();
+ return (csw);
+}
+
+void
+dev_relthread(struct cdev *dev)
+{
+
+ mtx_assert(&devmtx, MA_NOTOWNED);
+ dev_lock();
+ dev->si_threadcount--;
+ dev_unlock();
+}
int
nullop(void)
OpenPOWER on IntegriCloud