aboutsummaryrefslogtreecommitdiffstats
path: root/net/atm
diff options
context:
space:
mode:
authorLi Zefan <lizf@cn.fujitsu.com>2010-02-08 18:21:51 -0500
committerDavid S. Miller <davem@davemloft.net>2010-02-10 15:31:10 -0500
commit67de792420be2daa1c6fec07ec8552af9ea0bde3 (patch)
tree5a0141ea6d3d0f6557a6bd9ec3351d00d6a95f58 /net/atm
parenta2b79b414df97a70c33f874b631e06830431d233 (diff)
net: atm: use seq_list_foo() helpers
Simplify seq_file code. Signed-off-by: Li Zefan <lizf@cn.fujitsu.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/atm')
-rw-r--r--net/atm/proc.c2
-rw-r--r--net/atm/resources.c18
2 files changed, 3 insertions, 17 deletions
diff --git a/net/atm/proc.c b/net/atm/proc.c
index 476779d845eb..7a96b2376bd7 100644
--- a/net/atm/proc.c
+++ b/net/atm/proc.c
@@ -238,7 +238,7 @@ static int atm_dev_seq_show(struct seq_file *seq, void *v)
238 "Itf Type ESI/\"MAC\"addr " 238 "Itf Type ESI/\"MAC\"addr "
239 "AAL(TX,err,RX,err,drop) ... [refcnt]\n"; 239 "AAL(TX,err,RX,err,drop) ... [refcnt]\n";
240 240
241 if (v == SEQ_START_TOKEN) 241 if (v == &atm_devs)
242 seq_puts(seq, atm_dev_banner); 242 seq_puts(seq, atm_dev_banner);
243 else { 243 else {
244 struct atm_dev *dev = list_entry(v, struct atm_dev, dev_list); 244 struct atm_dev *dev = list_entry(v, struct atm_dev, dev_list);
diff --git a/net/atm/resources.c b/net/atm/resources.c
index 447ed89205d8..90082904f20d 100644
--- a/net/atm/resources.c
+++ b/net/atm/resources.c
@@ -444,21 +444,10 @@ done:
444 return error; 444 return error;
445} 445}
446 446
447static inline void *dev_get_idx(loff_t left)
448{
449 struct list_head *p;
450
451 list_for_each(p, &atm_devs) {
452 if (!--left)
453 break;
454 }
455 return (p != &atm_devs) ? p : NULL;
456}
457
458void *atm_dev_seq_start(struct seq_file *seq, loff_t *pos) 447void *atm_dev_seq_start(struct seq_file *seq, loff_t *pos)
459{ 448{
460 mutex_lock(&atm_dev_mutex); 449 mutex_lock(&atm_dev_mutex);
461 return *pos ? dev_get_idx(*pos) : SEQ_START_TOKEN; 450 return seq_list_start_head(&atm_devs, *pos);
462} 451}
463 452
464void atm_dev_seq_stop(struct seq_file *seq, void *v) 453void atm_dev_seq_stop(struct seq_file *seq, void *v)
@@ -468,8 +457,5 @@ void atm_dev_seq_stop(struct seq_file *seq, void *v)
468 457
469void *atm_dev_seq_next(struct seq_file *seq, void *v, loff_t *pos) 458void *atm_dev_seq_next(struct seq_file *seq, void *v, loff_t *pos)
470{ 459{
471 ++*pos; 460 return seq_list_next(v, &atm_devs, pos);
472 v = (v == SEQ_START_TOKEN)
473 ? atm_devs.next : ((struct list_head *)v)->next;
474 return (v == &atm_devs) ? NULL : v;
475} 461}