aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/tty.h
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-04-08 14:51:30 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-04-15 10:26:58 +0200
commit6c80c0b94b94192d9a34b400f8237703c6475f4d (patch)
tree2e4cdf5a94b5923315d00abe771f91314902d133 /drivers/tty/tty.h
parenttty: audit: move some local functions out of tty.h (diff)
downloadlinux-dev-6c80c0b94b94192d9a34b400f8237703c6475f4d.tar.xz
linux-dev-6c80c0b94b94192d9a34b400f8237703c6475f4d.zip
tty: move some internal tty lock enums and functions out of tty.h
Move the TTY_LOCK_* enums and tty_ldisc lock functions out of the global tty.h into the local header file to clean things up. Cc: Jiri Slaby <jirislaby@kernel.org> Link: https://lore.kernel.org/r/20210408125134.3016837-10-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/tty.h')
-rw-r--r--drivers/tty/tty.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/drivers/tty/tty.h b/drivers/tty/tty.h
index 55003840cd68..af997a4174c5 100644
--- a/drivers/tty/tty.h
+++ b/drivers/tty/tty.h
@@ -17,6 +17,32 @@
#define tty_info_ratelimited(tty, f, ...) \
tty_msg(pr_info_ratelimited, tty, f, ##__VA_ARGS__)
+/*
+ * Lock subclasses for tty locks
+ *
+ * TTY_LOCK_NORMAL is for normal ttys and master ptys.
+ * TTY_LOCK_SLAVE is for slave ptys only.
+ *
+ * Lock subclasses are necessary for handling nested locking with pty pairs.
+ * tty locks which use nested locking:
+ *
+ * legacy_mutex - Nested tty locks are necessary for releasing pty pairs.
+ * The stable lock order is master pty first, then slave pty.
+ * termios_rwsem - The stable lock order is tty_buffer lock->termios_rwsem.
+ * Subclassing this lock enables the slave pty to hold its
+ * termios_rwsem when claiming the master tty_buffer lock.
+ * tty_buffer lock - slave ptys can claim nested buffer lock when handling
+ * signal chars. The stable lock order is slave pty, then
+ * master.
+ */
+enum {
+ TTY_LOCK_NORMAL = 0,
+ TTY_LOCK_SLAVE,
+};
+
+int tty_ldisc_lock(struct tty_struct *tty, unsigned long timeout);
+void tty_ldisc_unlock(struct tty_struct *tty);
+
/* tty_audit.c */
#ifdef CONFIG_AUDIT
void tty_audit_add_data(struct tty_struct *tty, const void *data, size_t size);