1 // SPDX-License-Identifier: GPL-2.0
3 #include <linux/module.h>
4 #include <linux/kallsyms.h>
5 #include <linux/semaphore.h>
6 #include <linux/sched.h>
9 /* Legacy tty mutex glue */
12 * Getting the big tty mutex.
15 void tty_lock(struct tty_struct *tty)
17 if (WARN(tty->magic != TTY_MAGIC, "L Bad %p\n", tty))
20 mutex_lock(&tty->legacy_mutex);
22 EXPORT_SYMBOL(tty_lock);
24 int tty_lock_interruptible(struct tty_struct *tty)
28 if (WARN(tty->magic != TTY_MAGIC, "L Bad %p\n", tty))
31 ret = mutex_lock_interruptible(&tty->legacy_mutex);
37 void tty_unlock(struct tty_struct *tty)
39 if (WARN(tty->magic != TTY_MAGIC, "U Bad %p\n", tty))
41 mutex_unlock(&tty->legacy_mutex);
44 EXPORT_SYMBOL(tty_unlock);
46 void tty_lock_slave(struct tty_struct *tty)
48 if (tty && tty != tty->link)
52 void tty_unlock_slave(struct tty_struct *tty)
54 if (tty && tty != tty->link)
58 void tty_set_lock_subclass(struct tty_struct *tty)
60 lockdep_set_subclass(&tty->legacy_mutex, TTY_LOCK_SLAVE);