summaryrefslogtreecommitdiff
path: root/drivers/tty/tty_mutex.c
diff options
context:
space:
mode:
authorPeter Hurley <peter@hurleysoftware.com>2014-11-05 20:13:02 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-11-06 05:50:42 +0300
commit2febdb632bb96235b94b8fccaf882a78f8f4b2bb (patch)
treef4740b43b225a863f05df7edb59d3b3badfdb445 /drivers/tty/tty_mutex.c
parent2aff5e2bc62db43e05c814461a08aff0fc2b7fe5 (diff)
downloadlinux-2febdb632bb96235b94b8fccaf882a78f8f4b2bb.tar.xz
tty: Preset lock subclass for nested tty locks
Eliminate the requirement of specifying the tty lock nesting at lock time; instead, set the lock subclass for slave ptys at pty install (normal ttys and master ptys use subclass 0). Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/tty_mutex.c')
-rw-r--r--drivers/tty/tty_mutex.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/drivers/tty/tty_mutex.c b/drivers/tty/tty_mutex.c
index f43e995c7a0f..4486741190c4 100644
--- a/drivers/tty/tty_mutex.c
+++ b/drivers/tty/tty_mutex.c
@@ -13,15 +13,14 @@
enum {
TTY_MUTEX_NORMAL,
- TTY_MUTEX_NESTED,
+ TTY_MUTEX_SLAVE,
};
/*
* Getting the big tty mutex.
*/
-static void __lockfunc tty_lock_nested(struct tty_struct *tty,
- unsigned int subclass)
+void __lockfunc tty_lock(struct tty_struct *tty)
{
if (tty->magic != TTY_MAGIC) {
pr_err("L Bad %p\n", tty);
@@ -29,12 +28,7 @@ static void __lockfunc tty_lock_nested(struct tty_struct *tty,
return;
}
tty_kref_get(tty);
- mutex_lock_nested(&tty->legacy_mutex, subclass);
-}
-
-void __lockfunc tty_lock(struct tty_struct *tty)
-{
- return tty_lock_nested(tty, TTY_MUTEX_NORMAL);
+ mutex_lock(&tty->legacy_mutex);
}
EXPORT_SYMBOL(tty_lock);
@@ -56,7 +50,7 @@ void __lockfunc tty_lock_slave(struct tty_struct *tty)
WARN_ON(!mutex_is_locked(&tty->link->legacy_mutex) ||
!tty->driver->type == TTY_DRIVER_TYPE_PTY ||
!tty->driver->type == PTY_TYPE_SLAVE);
- tty_lock_nested(tty, TTY_MUTEX_NESTED);
+ tty_lock(tty);
}
}
@@ -65,3 +59,8 @@ void __lockfunc tty_unlock_slave(struct tty_struct *tty)
if (tty && tty != tty->link)
tty_unlock(tty);
}
+
+void tty_set_lock_subclass(struct tty_struct *tty)
+{
+ lockdep_set_subclass(&tty->legacy_mutex, TTY_MUTEX_SLAVE);
+}