summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/kern/kern_conf.c25
-rw-r--r--sys/sys/conf.h3
2 files changed, 28 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)
diff --git a/sys/sys/conf.h b/sys/sys/conf.h
index eed4b4b..426bc2f 100644
--- a/sys/sys/conf.h
+++ b/sys/sys/conf.h
@@ -61,6 +61,7 @@ struct cdev {
#define SI_DUMPDEV 0x0080 /* is kernel dumpdev */
#define SI_CANDELETE 0x0100 /* can do BIO_DELETE */
#define SI_CLONELIST 0x0200 /* on a clone list */
+#define SI_ISDISK 0x0400 /* device is a disk */
struct timespec si_atime;
struct timespec si_ctime;
struct timespec si_mtime;
@@ -261,6 +262,8 @@ int clone_create(struct clonedevs **, struct cdevsw *, int *unit, struct cdev **
int count_dev(struct cdev *_dev);
void destroy_dev(struct cdev *_dev);
struct cdevsw *devsw(struct cdev *_dev);
+struct cdevsw *dev_refthread(struct cdev *_dev);
+void dev_relthread(struct cdev *_dev);
const char *devtoname(struct cdev *_dev);
int dev_named(struct cdev *_pdev, const char *_name);
void dev_depends(struct cdev *_pdev, struct cdev *_cdev);
OpenPOWER on IntegriCloud