diff options
author | Andrea Bastoni <bastoni@cs.unc.edu> | 2010-05-30 19:16:45 -0400 |
---|---|---|
committer | Andrea Bastoni <bastoni@cs.unc.edu> | 2010-05-30 19:16:45 -0400 |
commit | ada47b5fe13d89735805b566185f4885f5a3f750 (patch) | |
tree | 644b88f8a71896307d71438e9b3af49126ffb22b /net/x25/x25_proc.c | |
parent | 43e98717ad40a4ae64545b5ba047c7b86aa44f4f (diff) | |
parent | 3280f21d43ee541f97f8cda5792150d2dbec20d5 (diff) |
Merge branch 'wip-2.6.34' into old-private-masterarchived-private-master
Diffstat (limited to 'net/x25/x25_proc.c')
-rw-r--r-- | net/x25/x25_proc.c | 114 |
1 files changed, 11 insertions, 103 deletions
diff --git a/net/x25/x25_proc.c b/net/x25/x25_proc.c index 0a04e62e0e18..7ff373792324 100644 --- a/net/x25/x25_proc.c +++ b/net/x25/x25_proc.c | |||
@@ -25,49 +25,17 @@ | |||
25 | #include <net/x25.h> | 25 | #include <net/x25.h> |
26 | 26 | ||
27 | #ifdef CONFIG_PROC_FS | 27 | #ifdef CONFIG_PROC_FS |
28 | static __inline__ struct x25_route *x25_get_route_idx(loff_t pos) | ||
29 | { | ||
30 | struct list_head *route_entry; | ||
31 | struct x25_route *rt = NULL; | ||
32 | |||
33 | list_for_each(route_entry, &x25_route_list) { | ||
34 | rt = list_entry(route_entry, struct x25_route, node); | ||
35 | if (!pos--) | ||
36 | goto found; | ||
37 | } | ||
38 | rt = NULL; | ||
39 | found: | ||
40 | return rt; | ||
41 | } | ||
42 | 28 | ||
43 | static void *x25_seq_route_start(struct seq_file *seq, loff_t *pos) | 29 | static void *x25_seq_route_start(struct seq_file *seq, loff_t *pos) |
44 | __acquires(x25_route_list_lock) | 30 | __acquires(x25_route_list_lock) |
45 | { | 31 | { |
46 | loff_t l = *pos; | ||
47 | |||
48 | read_lock_bh(&x25_route_list_lock); | 32 | read_lock_bh(&x25_route_list_lock); |
49 | return l ? x25_get_route_idx(--l) : SEQ_START_TOKEN; | 33 | return seq_list_start_head(&x25_route_list, *pos); |
50 | } | 34 | } |
51 | 35 | ||
52 | static void *x25_seq_route_next(struct seq_file *seq, void *v, loff_t *pos) | 36 | static void *x25_seq_route_next(struct seq_file *seq, void *v, loff_t *pos) |
53 | { | 37 | { |
54 | struct x25_route *rt; | 38 | return seq_list_next(v, &x25_route_list, pos); |
55 | |||
56 | ++*pos; | ||
57 | if (v == SEQ_START_TOKEN) { | ||
58 | rt = NULL; | ||
59 | if (!list_empty(&x25_route_list)) | ||
60 | rt = list_entry(x25_route_list.next, | ||
61 | struct x25_route, node); | ||
62 | goto out; | ||
63 | } | ||
64 | rt = v; | ||
65 | if (rt->node.next != &x25_route_list) | ||
66 | rt = list_entry(rt->node.next, struct x25_route, node); | ||
67 | else | ||
68 | rt = NULL; | ||
69 | out: | ||
70 | return rt; | ||
71 | } | 39 | } |
72 | 40 | ||
73 | static void x25_seq_route_stop(struct seq_file *seq, void *v) | 41 | static void x25_seq_route_stop(struct seq_file *seq, void *v) |
@@ -78,9 +46,9 @@ static void x25_seq_route_stop(struct seq_file *seq, void *v) | |||
78 | 46 | ||
79 | static int x25_seq_route_show(struct seq_file *seq, void *v) | 47 | static int x25_seq_route_show(struct seq_file *seq, void *v) |
80 | { | 48 | { |
81 | struct x25_route *rt; | 49 | struct x25_route *rt = list_entry(v, struct x25_route, node); |
82 | 50 | ||
83 | if (v == SEQ_START_TOKEN) { | 51 | if (v == &x25_route_list) { |
84 | seq_puts(seq, "Address Digits Device\n"); | 52 | seq_puts(seq, "Address Digits Device\n"); |
85 | goto out; | 53 | goto out; |
86 | } | 54 | } |
@@ -93,40 +61,16 @@ out: | |||
93 | return 0; | 61 | return 0; |
94 | } | 62 | } |
95 | 63 | ||
96 | static __inline__ struct sock *x25_get_socket_idx(loff_t pos) | ||
97 | { | ||
98 | struct sock *s; | ||
99 | struct hlist_node *node; | ||
100 | |||
101 | sk_for_each(s, node, &x25_list) | ||
102 | if (!pos--) | ||
103 | goto found; | ||
104 | s = NULL; | ||
105 | found: | ||
106 | return s; | ||
107 | } | ||
108 | |||
109 | static void *x25_seq_socket_start(struct seq_file *seq, loff_t *pos) | 64 | static void *x25_seq_socket_start(struct seq_file *seq, loff_t *pos) |
110 | __acquires(x25_list_lock) | 65 | __acquires(x25_list_lock) |
111 | { | 66 | { |
112 | loff_t l = *pos; | ||
113 | |||
114 | read_lock_bh(&x25_list_lock); | 67 | read_lock_bh(&x25_list_lock); |
115 | return l ? x25_get_socket_idx(--l) : SEQ_START_TOKEN; | 68 | return seq_hlist_start_head(&x25_list, *pos); |
116 | } | 69 | } |
117 | 70 | ||
118 | static void *x25_seq_socket_next(struct seq_file *seq, void *v, loff_t *pos) | 71 | static void *x25_seq_socket_next(struct seq_file *seq, void *v, loff_t *pos) |
119 | { | 72 | { |
120 | struct sock *s; | 73 | return seq_hlist_next(v, &x25_list, pos); |
121 | |||
122 | ++*pos; | ||
123 | if (v == SEQ_START_TOKEN) { | ||
124 | s = sk_head(&x25_list); | ||
125 | goto out; | ||
126 | } | ||
127 | s = sk_next(v); | ||
128 | out: | ||
129 | return s; | ||
130 | } | 74 | } |
131 | 75 | ||
132 | static void x25_seq_socket_stop(struct seq_file *seq, void *v) | 76 | static void x25_seq_socket_stop(struct seq_file *seq, void *v) |
@@ -148,7 +92,7 @@ static int x25_seq_socket_show(struct seq_file *seq, void *v) | |||
148 | goto out; | 92 | goto out; |
149 | } | 93 | } |
150 | 94 | ||
151 | s = v; | 95 | s = sk_entry(v); |
152 | x25 = x25_sk(s); | 96 | x25 = x25_sk(s); |
153 | 97 | ||
154 | if (!x25->neighbour || (dev = x25->neighbour->dev) == NULL) | 98 | if (!x25->neighbour || (dev = x25->neighbour->dev) == NULL) |
@@ -170,51 +114,16 @@ out: | |||
170 | return 0; | 114 | return 0; |
171 | } | 115 | } |
172 | 116 | ||
173 | static __inline__ struct x25_forward *x25_get_forward_idx(loff_t pos) | ||
174 | { | ||
175 | struct x25_forward *f; | ||
176 | struct list_head *entry; | ||
177 | |||
178 | list_for_each(entry, &x25_forward_list) { | ||
179 | f = list_entry(entry, struct x25_forward, node); | ||
180 | if (!pos--) | ||
181 | goto found; | ||
182 | } | ||
183 | |||
184 | f = NULL; | ||
185 | found: | ||
186 | return f; | ||
187 | } | ||
188 | |||
189 | static void *x25_seq_forward_start(struct seq_file *seq, loff_t *pos) | 117 | static void *x25_seq_forward_start(struct seq_file *seq, loff_t *pos) |
190 | __acquires(x25_forward_list_lock) | 118 | __acquires(x25_forward_list_lock) |
191 | { | 119 | { |
192 | loff_t l = *pos; | ||
193 | |||
194 | read_lock_bh(&x25_forward_list_lock); | 120 | read_lock_bh(&x25_forward_list_lock); |
195 | return l ? x25_get_forward_idx(--l) : SEQ_START_TOKEN; | 121 | return seq_list_start_head(&x25_forward_list, *pos); |
196 | } | 122 | } |
197 | 123 | ||
198 | static void *x25_seq_forward_next(struct seq_file *seq, void *v, loff_t *pos) | 124 | static void *x25_seq_forward_next(struct seq_file *seq, void *v, loff_t *pos) |
199 | { | 125 | { |
200 | struct x25_forward *f; | 126 | return seq_list_next(v, &x25_forward_list, pos); |
201 | |||
202 | ++*pos; | ||
203 | if (v == SEQ_START_TOKEN) { | ||
204 | f = NULL; | ||
205 | if (!list_empty(&x25_forward_list)) | ||
206 | f = list_entry(x25_forward_list.next, | ||
207 | struct x25_forward, node); | ||
208 | goto out; | ||
209 | } | ||
210 | f = v; | ||
211 | if (f->node.next != &x25_forward_list) | ||
212 | f = list_entry(f->node.next, struct x25_forward, node); | ||
213 | else | ||
214 | f = NULL; | ||
215 | out: | ||
216 | return f; | ||
217 | |||
218 | } | 127 | } |
219 | 128 | ||
220 | static void x25_seq_forward_stop(struct seq_file *seq, void *v) | 129 | static void x25_seq_forward_stop(struct seq_file *seq, void *v) |
@@ -225,9 +134,9 @@ static void x25_seq_forward_stop(struct seq_file *seq, void *v) | |||
225 | 134 | ||
226 | static int x25_seq_forward_show(struct seq_file *seq, void *v) | 135 | static int x25_seq_forward_show(struct seq_file *seq, void *v) |
227 | { | 136 | { |
228 | struct x25_forward *f; | 137 | struct x25_forward *f = list_entry(v, struct x25_forward, node); |
229 | 138 | ||
230 | if (v == SEQ_START_TOKEN) { | 139 | if (v == &x25_forward_list) { |
231 | seq_printf(seq, "lci dev1 dev2\n"); | 140 | seq_printf(seq, "lci dev1 dev2\n"); |
232 | goto out; | 141 | goto out; |
233 | } | 142 | } |
@@ -236,7 +145,6 @@ static int x25_seq_forward_show(struct seq_file *seq, void *v) | |||
236 | 145 | ||
237 | seq_printf(seq, "%d %-10s %-10s\n", | 146 | seq_printf(seq, "%d %-10s %-10s\n", |
238 | f->lci, f->dev1->name, f->dev2->name); | 147 | f->lci, f->dev1->name, f->dev2->name); |
239 | |||
240 | out: | 148 | out: |
241 | return 0; | 149 | return 0; |
242 | } | 150 | } |