diff options
| author | Ed Schouten <ed@FreeBSD.org> | 2009-05-11 18:52:46 +0000 |
|---|---|---|
| committer | Ed Schouten <ed@FreeBSD.org> | 2009-05-11 18:52:46 +0000 |
| commit | 7fb6f68587c6df50b08f7c11a8a56699f41a9f40 (patch) | |
| tree | 2442b7bf3363009cefac2412000d570c50d51c59 /sys/dev/snp/snp.c | |
| parent | 70839889c667b595faada0bbb777afcf1b3955c8 (diff) | |
Notes
Diffstat (limited to 'sys/dev/snp/snp.c')
| -rw-r--r-- | sys/dev/snp/snp.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/sys/dev/snp/snp.c b/sys/dev/snp/snp.c index 4a480372eba6..52c5a025b577 100644 --- a/sys/dev/snp/snp.c +++ b/sys/dev/snp/snp.c @@ -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, caddr_t data, int flags, 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); |
