diff options
author | Li Zefan <lizf@cn.fujitsu.com> | 2009-08-17 01:40:17 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-08-17 03:54:40 -0400 |
commit | 8109e1de8502421f9efff1359f2779b1adcc0724 (patch) | |
tree | 6d5dde3cc239370b6910c3e4004916531e0e5a91 /kernel/lockdep_proc.c | |
parent | e9d65725bdf5954283625ca4d770bfc34f2ae56a (diff) |
lockdep: Simplify lockdep seqfile code
Use seq_list_start_head() and seq_list_next().
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Cc: Peter Zijlstra <peterz@infradead.org>
LKML-Reference: <4A88ED41.5000000@cn.fujitsu.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/lockdep_proc.c')
-rw-r--r-- | kernel/lockdep_proc.c | 46 |
1 files changed, 5 insertions, 41 deletions
diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c index 9a7996e371f5..05fb5fde9b17 100644 --- a/kernel/lockdep_proc.c +++ b/kernel/lockdep_proc.c | |||
@@ -25,38 +25,12 @@ | |||
25 | 25 | ||
26 | static void *l_next(struct seq_file *m, void *v, loff_t *pos) | 26 | static void *l_next(struct seq_file *m, void *v, loff_t *pos) |
27 | { | 27 | { |
28 | struct lock_class *class; | 28 | return seq_list_next(v, &all_lock_classes, pos); |
29 | |||
30 | (*pos)++; | ||
31 | |||
32 | if (v == SEQ_START_TOKEN) | ||
33 | class = m->private; | ||
34 | else { | ||
35 | class = v; | ||
36 | |||
37 | if (class->lock_entry.next != &all_lock_classes) | ||
38 | class = list_entry(class->lock_entry.next, | ||
39 | struct lock_class, lock_entry); | ||
40 | else | ||
41 | class = NULL; | ||
42 | } | ||
43 | |||
44 | return class; | ||
45 | } | 29 | } |
46 | 30 | ||
47 | static void *l_start(struct seq_file *m, loff_t *pos) | 31 | static void *l_start(struct seq_file *m, loff_t *pos) |
48 | { | 32 | { |
49 | struct lock_class *class; | 33 | return seq_list_start_head(&all_lock_classes, *pos); |
50 | loff_t i = 0; | ||
51 | |||
52 | if (*pos == 0) | ||
53 | return SEQ_START_TOKEN; | ||
54 | |||
55 | list_for_each_entry(class, &all_lock_classes, lock_entry) { | ||
56 | if (++i == *pos) | ||
57 | return class; | ||
58 | } | ||
59 | return NULL; | ||
60 | } | 34 | } |
61 | 35 | ||
62 | static void l_stop(struct seq_file *m, void *v) | 36 | static void l_stop(struct seq_file *m, void *v) |
@@ -82,11 +56,11 @@ static void print_name(struct seq_file *m, struct lock_class *class) | |||
82 | 56 | ||
83 | static int l_show(struct seq_file *m, void *v) | 57 | static int l_show(struct seq_file *m, void *v) |
84 | { | 58 | { |
85 | struct lock_class *class = v; | 59 | struct lock_class *class = list_entry(v, struct lock_class, lock_entry); |
86 | struct lock_list *entry; | 60 | struct lock_list *entry; |
87 | char usage[LOCK_USAGE_CHARS]; | 61 | char usage[LOCK_USAGE_CHARS]; |
88 | 62 | ||
89 | if (v == SEQ_START_TOKEN) { | 63 | if (v == &all_lock_classes) { |
90 | seq_printf(m, "all lock classes:\n"); | 64 | seq_printf(m, "all lock classes:\n"); |
91 | return 0; | 65 | return 0; |
92 | } | 66 | } |
@@ -128,17 +102,7 @@ static const struct seq_operations lockdep_ops = { | |||
128 | 102 | ||
129 | static int lockdep_open(struct inode *inode, struct file *file) | 103 | static int lockdep_open(struct inode *inode, struct file *file) |
130 | { | 104 | { |
131 | int res = seq_open(file, &lockdep_ops); | 105 | return seq_open(file, &lockdep_ops); |
132 | if (!res) { | ||
133 | struct seq_file *m = file->private_data; | ||
134 | |||
135 | if (!list_empty(&all_lock_classes)) | ||
136 | m->private = list_entry(all_lock_classes.next, | ||
137 | struct lock_class, lock_entry); | ||
138 | else | ||
139 | m->private = NULL; | ||
140 | } | ||
141 | return res; | ||
142 | } | 106 | } |
143 | 107 | ||
144 | static const struct file_operations proc_lockdep_operations = { | 108 | static const struct file_operations proc_lockdep_operations = { |