Merge git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf
[deliverable/linux.git] / 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 (WARN(tty->magic != TTY_MAGIC, "L Bad %p\n", tty))
16 return;
17 tty_kref_get(tty);
18 mutex_lock(&tty->legacy_mutex);
19 }
20 EXPORT_SYMBOL(tty_lock);
21
22 int tty_lock_interruptible(struct tty_struct *tty)
23 {
24 if (WARN(tty->magic != TTY_MAGIC, "L Bad %p\n", tty))
25 return -EIO;
26 tty_kref_get(tty);
27 return mutex_lock_interruptible(&tty->legacy_mutex);
28 }
29
30 void __lockfunc tty_unlock(struct tty_struct *tty)
31 {
32 if (WARN(tty->magic != TTY_MAGIC, "U Bad %p\n", tty))
33 return;
34 mutex_unlock(&tty->legacy_mutex);
35 tty_kref_put(tty);
36 }
37 EXPORT_SYMBOL(tty_unlock);
38
39 void __lockfunc tty_lock_slave(struct tty_struct *tty)
40 {
41 if (tty && tty != tty->link)
42 tty_lock(tty);
43 }
44
45 void __lockfunc tty_unlock_slave(struct tty_struct *tty)
46 {
47 if (tty && tty != tty->link)
48 tty_unlock(tty);
49 }
50
51 void tty_set_lock_subclass(struct tty_struct *tty)
52 {
53 lockdep_set_subclass(&tty->legacy_mutex, TTY_LOCK_SLAVE);
54 }
This page took 0.033339 seconds and 6 git commands to generate.