852 return NULL;
853}
854
855static struct hlist_node *get_next(struct iter_state *st, struct hlist_node *h)
856{
857 h = h->next;
858 while (!h) {
859 if (++st->bucket >= INSTANCE_BUCKETS)
860 return NULL;
861
862 h = instance_table[st->bucket].first;
863 }
864 return h;
865}
866
867static struct hlist_node *get_idx(struct iter_state *st, loff_t pos)
868{
869 struct hlist_node *head;
870 head = get_first(st);
871
872 if (head)
873 while (pos && (head = get_next(st, head)))
874 pos--;
875 return pos ? NULL : head;
876}
877
878static void *seq_start(struct seq_file *seq, loff_t *pos)
879 __acquires(instances_lock)
880{
881 read_lock_bh(&instances_lock);
882 return get_idx(seq->private, *pos);
883}
884
885static void *seq_next(struct seq_file *s, void *v, loff_t *pos)
886{
887 (*pos)++;
888 return get_next(s->private, v);
889}
890
891static void seq_stop(struct seq_file *s, void *v)
892 __releases(instances_lock)