diff options
author | Eric Dumazet <edumazet@google.com> | 2012-05-31 11:35:18 +0200 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-05-31 11:59:41 -0700 |
commit | fde86d310886372a377213251e72fb87aaa406c9 (patch) | |
tree | d0131cf044535b71710dd61ee78b4810f5545ac3 /drivers | |
parent | 1d59d61f606547f0712aa6971f91f71154071c99 (diff) |
tty: add lockdep annotations
tty_lock_pair() do the right thing to avoid deadlocks, but should
instruct LOCKDEP of this to avoid a splat.
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/tty/tty_mutex.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/drivers/tty/tty_mutex.c b/drivers/tty/tty_mutex.c index 69adc80c98cd..67feac9e6ebb 100644 --- a/drivers/tty/tty_mutex.c +++ b/drivers/tty/tty_mutex.c @@ -6,11 +6,17 @@ /* Legacy tty mutex glue */ +enum { + TTY_MUTEX_NORMAL, + TTY_MUTEX_NESTED, +}; + /* * Getting the big tty mutex. */ -void __lockfunc tty_lock(struct tty_struct *tty) +static void __lockfunc tty_lock_nested(struct tty_struct *tty, + unsigned int subclass) { if (tty->magic != TTY_MAGIC) { printk(KERN_ERR "L Bad %p\n", tty); @@ -18,7 +24,12 @@ void __lockfunc tty_lock(struct tty_struct *tty) return; } tty_kref_get(tty); - mutex_lock(&tty->legacy_mutex); + mutex_lock_nested(&tty->legacy_mutex, subclass); +} + +void __lockfunc tty_lock(struct tty_struct *tty) +{ + return tty_lock_nested(tty, TTY_MUTEX_NORMAL); } EXPORT_SYMBOL(tty_lock); @@ -43,11 +54,11 @@ void __lockfunc tty_lock_pair(struct tty_struct *tty, { if (tty < tty2) { tty_lock(tty); - tty_lock(tty2); + tty_lock_nested(tty2, TTY_MUTEX_NESTED); } else { if (tty2 && tty2 != tty) tty_lock(tty2); - tty_lock(tty); + tty_lock_nested(tty, TTY_MUTEX_NESTED); } } EXPORT_SYMBOL(tty_lock_pair); |