aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/lockdep_proc.c
diff options
context:
space:
mode:
authorLi Zefan <lizf@cn.fujitsu.com>2009-08-17 01:40:59 -0400
committerIngo Molnar <mingo@elte.hu>2009-08-17 03:54:41 -0400
commit96004bb2a1e4ccad2b1eeb92e51031d1e8e609e3 (patch)
tree50ddfa66620a2bdb386ac901c11f23fb8fdce492 /kernel/lockdep_proc.c
parent12aac19d4ba41019a1748f49d3c5d259b1bfb26d (diff)
lockdep: Simplify lock_stat seqfile code
- make ls_next() call ls_start() - remove redundant code in lock_stat_release() Signed-off-by: Li Zefan <lizf@cn.fujitsu.com> Cc: Peter Zijlstra <peterz@infradead.org> LKML-Reference: <4A88ED6B.6030602@cn.fujitsu.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/lockdep_proc.c')
-rw-r--r--kernel/lockdep_proc.c29
1 files changed, 7 insertions, 22 deletions
diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
index 2bbe25f55d09..8dac8402e07e 100644
--- a/kernel/lockdep_proc.c
+++ b/kernel/lockdep_proc.c
@@ -383,7 +383,6 @@ struct lock_stat_data {
383}; 383};
384 384
385struct lock_stat_seq { 385struct lock_stat_seq {
386 struct lock_stat_data *iter;
387 struct lock_stat_data *iter_end; 386 struct lock_stat_data *iter_end;
388 struct lock_stat_data stats[MAX_LOCKDEP_KEYS]; 387 struct lock_stat_data stats[MAX_LOCKDEP_KEYS];
389}; 388};
@@ -571,34 +570,22 @@ static void seq_header(struct seq_file *m)
571static void *ls_start(struct seq_file *m, loff_t *pos) 570static void *ls_start(struct seq_file *m, loff_t *pos)
572{ 571{
573 struct lock_stat_seq *data = m->private; 572 struct lock_stat_seq *data = m->private;
573 struct lock_stat_data *iter;
574 574
575 if (*pos == 0) 575 if (*pos == 0)
576 return SEQ_START_TOKEN; 576 return SEQ_START_TOKEN;
577 577
578 data->iter = data->stats + (*pos - 1); 578 iter = data->stats + (*pos - 1);
579 if (data->iter >= data->iter_end) 579 if (iter >= data->iter_end)
580 data->iter = NULL; 580 iter = NULL;
581 581
582 return data->iter; 582 return iter;
583} 583}
584 584
585static void *ls_next(struct seq_file *m, void *v, loff_t *pos) 585static void *ls_next(struct seq_file *m, void *v, loff_t *pos)
586{ 586{
587 struct lock_stat_seq *data = m->private;
588
589 (*pos)++; 587 (*pos)++;
590 588 return ls_start(m, pos);
591 if (v == SEQ_START_TOKEN)
592 data->iter = data->stats;
593 else {
594 data->iter = v;
595 data->iter++;
596 }
597
598 if (data->iter == data->iter_end)
599 data->iter = NULL;
600
601 return data->iter;
602} 589}
603 590
604static void ls_stop(struct seq_file *m, void *v) 591static void ls_stop(struct seq_file *m, void *v)
@@ -636,7 +623,6 @@ static int lock_stat_open(struct inode *inode, struct file *file)
636 struct lock_stat_data *iter = data->stats; 623 struct lock_stat_data *iter = data->stats;
637 struct seq_file *m = file->private_data; 624 struct seq_file *m = file->private_data;
638 625
639 data->iter = iter;
640 list_for_each_entry(class, &all_lock_classes, lock_entry) { 626 list_for_each_entry(class, &all_lock_classes, lock_entry) {
641 iter->class = class; 627 iter->class = class;
642 iter->stats = lock_stats(class); 628 iter->stats = lock_stats(class);
@@ -644,7 +630,7 @@ static int lock_stat_open(struct inode *inode, struct file *file)
644 } 630 }
645 data->iter_end = iter; 631 data->iter_end = iter;
646 632
647 sort(data->stats, data->iter_end - data->iter, 633 sort(data->stats, data->iter_end - data->stats,
648 sizeof(struct lock_stat_data), 634 sizeof(struct lock_stat_data),
649 lock_stat_cmp, NULL); 635 lock_stat_cmp, NULL);
650 636
@@ -679,7 +665,6 @@ static int lock_stat_release(struct inode *inode, struct file *file)
679 struct seq_file *seq = file->private_data; 665 struct seq_file *seq = file->private_data;
680 666
681 vfree(seq->private); 667 vfree(seq->private);
682 seq->private = NULL;
683 return seq_release(inode, file); 668 return seq_release(inode, file);
684} 669}
685 670