svn commit: r191999 - head/sys/dev/snp
Ed Schouten
ed at FreeBSD.org
Mon May 11 18:52:47 UTC 2009
Author: ed
Date: Mon May 11 18:52:46 2009
New Revision: 191999
URL: http://svn.freebsd.org/changeset/base/191999
Log:
Add macros around the sx operations in snp(4).
As an experiment, I changed snp(4) to use a mutex instead of an sx lock.
We can't enable this right now, because Syscons still picks up Giant.
It's nice to already have the framework there.
Modified:
head/sys/dev/snp/snp.c
Modified: head/sys/dev/snp/snp.c
==============================================================================
--- head/sys/dev/snp/snp.c Mon May 11 18:45:04 2009 (r191998)
+++ head/sys/dev/snp/snp.c Mon May 11 18:52:46 2009 (r191999)
@@ -43,11 +43,22 @@ __FBSDID("$FreeBSD$");
#include <sys/uio.h>
static struct cdev *snp_dev;
+static MALLOC_DEFINE(M_SNP, "snp", "tty snoop device");
+
/* XXX: should be mtx, but TTY can be locked by Giant. */
+#if 0
+static struct mtx snp_register_lock;
+MTX_SYSINIT(snp_register_lock, &snp_register_lock,
+ "tty snoop registration", MTX_DEF);
+#define SNP_LOCK() mtx_lock(&snp_register_lock)
+#define SNP_UNLOCK() mtx_unlock(&snp_register_lock)
+#else
static struct sx snp_register_lock;
SX_SYSINIT(snp_register_lock, &snp_register_lock,
"tty snoop registration");
-static MALLOC_DEFINE(M_SNP, "snp", "tty snoop device");
+#define SNP_LOCK() sx_xlock(&snp_register_lock)
+#define SNP_UNLOCK() sx_xunlock(&snp_register_lock)
+#endif
/*
* There is no need to have a big input buffer. In most typical setups,
@@ -241,14 +252,14 @@ snp_ioctl(struct cdev *dev, u_long cmd,
switch (cmd) {
case SNPSTTY:
/* Bind TTY to snoop instance. */
- sx_xlock(&snp_register_lock);
+ SNP_LOCK();
if (ss->snp_tty != NULL) {
- sx_xunlock(&snp_register_lock);
+ SNP_UNLOCK();
return (EBUSY);
}
error = ttyhook_register(&ss->snp_tty, td->td_proc, *(int *)data,
&snp_hook, ss);
- sx_xunlock(&snp_register_lock);
+ SNP_UNLOCK();
if (error != 0)
return (error);
More information about the svn-src-head
mailing list