summaryrefslogtreecommitdiff
path: root/include/linux/tty.h
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2010-06-02 00:53:01 +0400
committerGreg Kroah-Hartman <gregkh@suse.de>2010-08-11 00:47:43 +0400
commitec79d6056de58511d8e46d9ae59d3878f958dc3e (patch)
tree8e73cf399c4cb3c31dbf3caced385cfc018a706a /include/linux/tty.h
parent3f582b8c11014e4ce310d9839fb335164195333f (diff)
downloadlinux-ec79d6056de58511d8e46d9ae59d3878f958dc3e.tar.xz
tty: replace BKL with a new tty_lock
As a preparation for replacing the big kernel lock in the TTY layer, wrap all the callers in new macros tty_lock, tty_lock_nested and tty_unlock. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Cc: Alan Cox <alan@lxorguk.ukuu.org.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'include/linux/tty.h')
-rw-r--r--include/linux/tty.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/include/linux/tty.h b/include/linux/tty.h
index 2df60e4ff40e..6ead6b60c743 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -13,6 +13,7 @@
#include <linux/tty_driver.h>
#include <linux/tty_ldisc.h>
#include <linux/mutex.h>
+#include <linux/smp_lock.h>
#include <asm/system.h>
@@ -576,5 +577,35 @@ extern int vt_ioctl(struct tty_struct *tty, struct file *file,
extern long vt_compat_ioctl(struct tty_struct *tty, struct file * file,
unsigned int cmd, unsigned long arg);
+/* functions for preparation of BKL removal */
+
+/*
+ * tty_lock_nested get the tty_lock while potentially holding it
+ *
+ * The Big TTY Mutex is a recursive lock, meaning you can take it
+ * from a thread that is already holding it.
+ * This is bad for a number of reasons, so tty_lock_nested should
+ * really be used as rarely as possible. If a code location can
+ * be shown to never get called with this held already, it should
+ * use tty_lock() instead.
+ */
+static inline void __lockfunc tty_lock_nested(void) __acquires(kernel_lock)
+{
+ lock_kernel();
+}
+static inline void tty_lock(void) __acquires(kernel_lock)
+{
+#ifdef CONFIG_LOCK_KERNEL
+ /* kernel_locked is 1 for !CONFIG_LOCK_KERNEL */
+ WARN_ON(kernel_locked());
+#endif
+ lock_kernel();
+}
+static inline void tty_unlock(void) __releases(kernel_lock)
+{
+ unlock_kernel();
+}
+#define tty_locked() (kernel_locked())
+
#endif /* __KERNEL__ */
#endif