Add the rt linux 4.1.3-rt3 as base
[kvmfornfv.git] / kernel / drivers / tty / tty_mutex.c
1 #include <linux/tty.h>
2 #include <linux/module.h>
3 #include <linux/kallsyms.h>
4 #include <linux/semaphore.h>
5 #include <linux/sched.h>
6
7 /* Legacy tty mutex glue */
8
9 /*
10  * Getting the big tty mutex.
11  */
12
13 void __lockfunc tty_lock(struct tty_struct *tty)
14 {
15         if (tty->magic != TTY_MAGIC) {
16                 pr_err("L Bad %p\n", tty);
17                 WARN_ON(1);
18                 return;
19         }
20         tty_kref_get(tty);
21         mutex_lock(&tty->legacy_mutex);
22 }
23 EXPORT_SYMBOL(tty_lock);
24
25 void __lockfunc tty_unlock(struct tty_struct *tty)
26 {
27         if (tty->magic != TTY_MAGIC) {
28                 pr_err("U Bad %p\n", tty);
29                 WARN_ON(1);
30                 return;
31         }
32         mutex_unlock(&tty->legacy_mutex);
33         tty_kref_put(tty);
34 }
35 EXPORT_SYMBOL(tty_unlock);
36
37 void __lockfunc tty_lock_slave(struct tty_struct *tty)
38 {
39         if (tty && tty != tty->link)
40                 tty_lock(tty);
41 }
42
43 void __lockfunc tty_unlock_slave(struct tty_struct *tty)
44 {
45         if (tty && tty != tty->link)
46                 tty_unlock(tty);
47 }
48
49 void tty_set_lock_subclass(struct tty_struct *tty)
50 {
51         lockdep_set_subclass(&tty->legacy_mutex, TTY_LOCK_SLAVE);
52 }