Staging: hv: hv_mouse: unwind the initialization process a bit
[zen-stable.git] / drivers / tty / tty_mutex.c
blob133697540c738441d6b92f6e2ebf72b0622baae6
1 /*
2 * drivers/char/tty_lock.c
3 */
4 #include <linux/tty.h>
5 #include <linux/module.h>
6 #include <linux/kallsyms.h>
7 #include <linux/semaphore.h>
8 #include <linux/sched.h>
11 * The 'big tty mutex'
13 * This mutex is taken and released by tty_lock() and tty_unlock(),
14 * replacing the older big kernel lock.
15 * It can no longer be taken recursively, and does not get
16 * released implicitly while sleeping.
18 * Don't use in new code.
20 static DEFINE_MUTEX(big_tty_mutex);
21 struct task_struct *__big_tty_mutex_owner;
22 EXPORT_SYMBOL_GPL(__big_tty_mutex_owner);
25 * Getting the big tty mutex.
27 void __lockfunc tty_lock(void)
29 struct task_struct *task = current;
31 WARN_ON(__big_tty_mutex_owner == task);
33 mutex_lock(&big_tty_mutex);
34 __big_tty_mutex_owner = task;
36 EXPORT_SYMBOL(tty_lock);
38 void __lockfunc tty_unlock(void)
40 struct task_struct *task = current;
42 WARN_ON(__big_tty_mutex_owner != task);
43 __big_tty_mutex_owner = NULL;
45 mutex_unlock(&big_tty_mutex);
47 EXPORT_SYMBOL(tty_unlock);