]>
git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blob - drivers/tty/tty_mutex.c
2 #include <linux/module.h>
3 #include <linux/kallsyms.h>
4 #include <linux/semaphore.h>
5 #include <linux/sched.h>
7 /* Legacy tty mutex glue */
15 * Getting the big tty mutex.
18 static void __lockfunc
tty_lock_nested(struct tty_struct
*tty
,
19 unsigned int subclass
)
21 if (tty
->magic
!= TTY_MAGIC
) {
22 pr_err("L Bad %p\n", tty
);
27 mutex_lock_nested(&tty
->legacy_mutex
, subclass
);
30 void __lockfunc
tty_lock(struct tty_struct
*tty
)
32 return tty_lock_nested(tty
, TTY_MUTEX_NORMAL
);
34 EXPORT_SYMBOL(tty_lock
);
36 void __lockfunc
tty_unlock(struct tty_struct
*tty
)
38 if (tty
->magic
!= TTY_MAGIC
) {
39 pr_err("U Bad %p\n", tty
);
43 mutex_unlock(&tty
->legacy_mutex
);
46 EXPORT_SYMBOL(tty_unlock
);
49 * Getting the big tty mutex for a pair of ttys with lock ordering
50 * On a non pty/tty pair tty2 can be NULL which is just fine.
52 void __lockfunc
tty_lock_pair(struct tty_struct
*tty
,
53 struct tty_struct
*tty2
)
57 tty_lock_nested(tty2
, TTY_MUTEX_NESTED
);
59 if (tty2
&& tty2
!= tty
)
61 tty_lock_nested(tty
, TTY_MUTEX_NESTED
);
64 EXPORT_SYMBOL(tty_lock_pair
);
66 void __lockfunc
tty_unlock_pair(struct tty_struct
*tty
,
67 struct tty_struct
*tty2
)
70 if (tty2
&& tty2
!= tty
)
73 EXPORT_SYMBOL(tty_unlock_pair
);