814
815static struct hlist_node *get_next(struct seq_file *seq, struct hlist_node *h)
816{
817 struct iter_state *st = seq->private;
818
819 h = h->next;
820 while (!h) {
821 if (++st->bucket >= INSTANCE_BUCKETS)
822 return NULL;
823
824 h = instance_table[st->bucket].first;
825 }
826 return h;
827}
828
829static struct hlist_node *get_idx(struct seq_file *seq, loff_t pos)
830{
831 struct hlist_node *head;
832 head = get_first(seq);
833
834 if (head)
835 while (pos && (head = get_next(seq, head)))
836 pos--;
837 return pos ? NULL : head;
838}
839
840static void *seq_start(struct seq_file *seq, loff_t *pos)
841 __acquires(instances_lock)
842{
843 spin_lock(&instances_lock);
844 return get_idx(seq, *pos);
845}
846
847static void *seq_next(struct seq_file *s, void *v, loff_t *pos)
848{
849 (*pos)++;
850 return get_next(s, v);
851}
852
853static void seq_stop(struct seq_file *s, void *v)
854 __releases(instances_lock)