2 #include <linux/module.h>
3 #include <linux/kallsyms.h>
4 #include <linux/semaphore.h>
5 #include <linux/sched.h>
8 * Nested tty locks are necessary for releasing pty pairs.
9 * The stable lock order is master pty first, then slave pty.
12 /* Legacy tty mutex glue */
20 * Getting the big tty mutex.
23 void __lockfunc tty_lock(struct tty_struct *tty)
25 if (tty->magic != TTY_MAGIC) {
26 pr_err("L Bad %p\n", tty);
31 mutex_lock(&tty->legacy_mutex);
33 EXPORT_SYMBOL(tty_lock);
35 void __lockfunc tty_unlock(struct tty_struct *tty)
37 if (tty->magic != TTY_MAGIC) {
38 pr_err("U Bad %p\n", tty);
42 mutex_unlock(&tty->legacy_mutex);
45 EXPORT_SYMBOL(tty_unlock);
47 void __lockfunc tty_lock_slave(struct tty_struct *tty)
49 if (tty && tty != tty->link)
53 void __lockfunc tty_unlock_slave(struct tty_struct *tty)
55 if (tty && tty != tty->link)
59 void tty_set_lock_subclass(struct tty_struct *tty)
61 lockdep_set_subclass(&tty->legacy_mutex, TTY_MUTEX_SLAVE);