diff options
author | Eric Dumazet <edumazet@google.com> | 2012-05-31 05:35:18 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-05-31 14:59:41 -0400 |
commit | fde86d310886372a377213251e72fb87aaa406c9 (patch) | |
tree | d0131cf044535b71710dd61ee78b4810f5545ac3 /drivers/tty/tty_mutex.c | |
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/tty/tty_mutex.c')
-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 @@ | |||
6 | 6 | ||
7 | /* Legacy tty mutex glue */ | 7 | /* Legacy tty mutex glue */ |
8 | 8 | ||
9 | enum { | ||
10 | TTY_MUTEX_NORMAL, | ||
11 | TTY_MUTEX_NESTED, | ||
12 | }; | ||
13 | |||
9 | /* | 14 | /* |
10 | * Getting the big tty mutex. | 15 | * Getting the big tty mutex. |
11 | */ | 16 | */ |
12 | 17 | ||
13 | void __lockfunc tty_lock(struct tty_struct *tty) | 18 | static void __lockfunc tty_lock_nested(struct tty_struct *tty, |
19 | unsigned int subclass) | ||
14 | { | 20 | { |
15 | if (tty->magic != TTY_MAGIC) { | 21 | if (tty->magic != TTY_MAGIC) { |
16 | printk(KERN_ERR "L Bad %p\n", tty); | 22 | printk(KERN_ERR "L Bad %p\n", tty); |
@@ -18,7 +24,12 @@ void __lockfunc tty_lock(struct tty_struct *tty) | |||
18 | return; | 24 | return; |
19 | } | 25 | } |
20 | tty_kref_get(tty); | 26 | tty_kref_get(tty); |
21 | mutex_lock(&tty->legacy_mutex); | 27 | mutex_lock_nested(&tty->legacy_mutex, subclass); |
28 | } | ||
29 | |||
30 | void __lockfunc tty_lock(struct tty_struct *tty) | ||
31 | { | ||
32 | return tty_lock_nested(tty, TTY_MUTEX_NORMAL); | ||
22 | } | 33 | } |
23 | EXPORT_SYMBOL(tty_lock); | 34 | EXPORT_SYMBOL(tty_lock); |
24 | 35 | ||
@@ -43,11 +54,11 @@ void __lockfunc tty_lock_pair(struct tty_struct *tty, | |||
43 | { | 54 | { |
44 | if (tty < tty2) { | 55 | if (tty < tty2) { |
45 | tty_lock(tty); | 56 | tty_lock(tty); |
46 | tty_lock(tty2); | 57 | tty_lock_nested(tty2, TTY_MUTEX_NESTED); |
47 | } else { | 58 | } else { |
48 | if (tty2 && tty2 != tty) | 59 | if (tty2 && tty2 != tty) |
49 | tty_lock(tty2); | 60 | tty_lock(tty2); |
50 | tty_lock(tty); | 61 | tty_lock_nested(tty, TTY_MUTEX_NESTED); |
51 | } | 62 | } |
52 | } | 63 | } |
53 | EXPORT_SYMBOL(tty_lock_pair); | 64 | EXPORT_SYMBOL(tty_lock_pair); |