aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/tty.h
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2010-06-01 16:53:01 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2010-08-10 16:47:43 -0400
commitec79d6056de58511d8e46d9ae59d3878f958dc3e (patch)
tree8e73cf399c4cb3c31dbf3caced385cfc018a706a /include/linux/tty.h
parent3f582b8c11014e4ce310d9839fb335164195333f (diff)
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 @@
13#include <linux/tty_driver.h> 13#include <linux/tty_driver.h>
14#include <linux/tty_ldisc.h> 14#include <linux/tty_ldisc.h>
15#include <linux/mutex.h> 15#include <linux/mutex.h>
16#include <linux/smp_lock.h>
16 17
17#include <asm/system.h> 18#include <asm/system.h>
18 19
@@ -576,5 +577,35 @@ extern int vt_ioctl(struct tty_struct *tty, struct file *file,
576extern long vt_compat_ioctl(struct tty_struct *tty, struct file * file, 577extern long vt_compat_ioctl(struct tty_struct *tty, struct file * file,
577 unsigned int cmd, unsigned long arg); 578 unsigned int cmd, unsigned long arg);
578 579
580/* functions for preparation of BKL removal */
581
582/*
583 * tty_lock_nested get the tty_lock while potentially holding it
584 *
585 * The Big TTY Mutex is a recursive lock, meaning you can take it
586 * from a thread that is already holding it.
587 * This is bad for a number of reasons, so tty_lock_nested should
588 * really be used as rarely as possible. If a code location can
589 * be shown to never get called with this held already, it should
590 * use tty_lock() instead.
591 */
592static inline void __lockfunc tty_lock_nested(void) __acquires(kernel_lock)
593{
594 lock_kernel();
595}
596static inline void tty_lock(void) __acquires(kernel_lock)
597{
598#ifdef CONFIG_LOCK_KERNEL
599 /* kernel_locked is 1 for !CONFIG_LOCK_KERNEL */
600 WARN_ON(kernel_locked());
601#endif
602 lock_kernel();
603}
604static inline void tty_unlock(void) __releases(kernel_lock)
605{
606 unlock_kernel();
607}
608#define tty_locked() (kernel_locked())
609
579#endif /* __KERNEL__ */ 610#endif /* __KERNEL__ */
580#endif 611#endif