Lines Matching refs:id
173 static void idr_mark_full(struct idr_layer **pa, int id) in idr_mark_full() argument
178 __set_bit(id & IDR_MASK, p->bitmap); in idr_mark_full()
188 id = id >> IDR_BITS; in idr_mark_full()
189 __set_bit((id & IDR_MASK), p->bitmap); in idr_mark_full()
226 int l, id, oid; in sub_alloc() local
228 id = *starting_id; in sub_alloc()
237 n = (id >> (IDR_BITS*l)) & IDR_MASK; in sub_alloc()
242 oid = id; in sub_alloc()
243 id = (id | ((1 << (IDR_BITS * l)) - 1)) + 1; in sub_alloc()
246 if (id > idr_max(idp->layers)) { in sub_alloc()
247 *starting_id = id; in sub_alloc()
257 if (oid >> sh == id >> sh) in sub_alloc()
264 id = ((id >> sh) ^ n ^ m) << sh; in sub_alloc()
266 if ((id >= MAX_IDR_BIT) || (id < 0)) in sub_alloc()
278 new->prefix = id & idr_layer_prefix_mask(new->layer); in sub_alloc()
287 return id; in sub_alloc()
295 int layers, v, id; in idr_get_empty_slot() local
298 id = starting_id; in idr_get_empty_slot()
312 while (id > idr_max(layers)) { in idr_get_empty_slot()
342 new->prefix = id & idr_layer_prefix_mask(new->layer); in idr_get_empty_slot()
349 v = sub_alloc(idp, &id, pa, gfp_mask, layer_idr); in idr_get_empty_slot()
359 static void idr_fill_slot(struct idr *idr, void *ptr, int id, in idr_fill_slot() argument
365 rcu_assign_pointer(pa[0]->ary[id & IDR_MASK], (struct idr_layer *)ptr); in idr_fill_slot()
367 idr_mark_full(pa, id); in idr_fill_slot()
455 int id; in idr_alloc() local
466 id = idr_get_empty_slot(idr, start, pa, gfp_mask, NULL); in idr_alloc()
467 if (unlikely(id < 0)) in idr_alloc()
468 return id; in idr_alloc()
469 if (unlikely(id > max)) in idr_alloc()
472 idr_fill_slot(idr, ptr, id, pa); in idr_alloc()
473 return id; in idr_alloc()
492 int id; in idr_alloc_cyclic() local
494 id = idr_alloc(idr, ptr, max(start, idr->cur), end, gfp_mask); in idr_alloc_cyclic()
495 if (id == -ENOSPC) in idr_alloc_cyclic()
496 id = idr_alloc(idr, ptr, start, end, gfp_mask); in idr_alloc_cyclic()
498 if (likely(id >= 0)) in idr_alloc_cyclic()
499 idr->cur = id + 1; in idr_alloc_cyclic()
500 return id; in idr_alloc_cyclic()
504 static void idr_remove_warning(int id) in idr_remove_warning() argument
506 WARN(1, "idr_remove called for id=%d which is not allocated.\n", id); in idr_remove_warning()
509 static void sub_remove(struct idr *idp, int shift, int id) in sub_remove() argument
521 n = (id >> shift) & IDR_MASK; in sub_remove()
527 n = id & IDR_MASK; in sub_remove()
543 idr_remove_warning(id); in sub_remove()
551 void idr_remove(struct idr *idp, int id) in idr_remove() argument
556 if (id < 0) in idr_remove()
559 if (id > idr_max(idp->layers)) { in idr_remove()
560 idr_remove_warning(id); in idr_remove()
564 sub_remove(idp, (idp->layers - 1) * IDR_BITS, id); in idr_remove()
586 int n, id, max; in __idr_remove_all() local
597 id = 0; in __idr_remove_all()
598 while (id >= 0 && id <= max) { in __idr_remove_all()
602 p = p->ary[(id >> n) & IDR_MASK]; in __idr_remove_all()
606 bt_mask = id; in __idr_remove_all()
607 id += 1 << n; in __idr_remove_all()
609 while (n < fls(id ^ bt_mask)) { in __idr_remove_all()
643 void *idr_find_slowpath(struct idr *idp, int id) in idr_find_slowpath() argument
648 if (id < 0) in idr_find_slowpath()
656 if (id > idr_max(p->layer + 1)) in idr_find_slowpath()
663 p = rcu_dereference_raw(p->ary[(id >> n) & IDR_MASK]); in idr_find_slowpath()
688 int (*fn)(int id, void *p, void *data), void *data) in idr_for_each() argument
690 int n, id, max, error = 0; in idr_for_each() local
699 id = 0; in idr_for_each()
700 while (id >= 0 && id <= max) { in idr_for_each()
704 p = rcu_dereference_raw(p->ary[(id >> n) & IDR_MASK]); in idr_for_each()
709 error = fn(id, (void *)p, data); in idr_for_each()
714 id += 1 << n; in idr_for_each()
715 while (n < fls(id)) { in idr_for_each()
741 int id = *nextidp; in idr_get_next() local
751 while (id >= 0 && id <= max) { in idr_get_next()
755 p = rcu_dereference_raw(p->ary[(id >> n) & IDR_MASK]); in idr_get_next()
760 *nextidp = id; in idr_get_next()
771 id = round_up(id + 1, 1 << n); in idr_get_next()
772 while (n < fls(id)) { in idr_get_next()
794 void *idr_replace(struct idr *idp, void *ptr, int id) in idr_replace() argument
799 if (id < 0) in idr_replace()
806 if (id > idr_max(p->layer + 1)) in idr_replace()
811 p = p->ary[(id >> n) & IDR_MASK]; in idr_replace()
815 n = id & IDR_MASK; in idr_replace()
846 static int idr_has_entry(int id, void *p, void *data) in idr_has_entry() argument
940 int t, id; in ida_get_new_above() local
981 id = idr_id * IDA_BITMAP_BITS + t; in ida_get_new_above()
982 if (id >= MAX_IDR_BIT) in ida_get_new_above()
989 *p_id = id; in ida_get_new_above()
1011 void ida_remove(struct ida *ida, int id) in ida_remove() argument
1015 int idr_id = id / IDA_BITMAP_BITS; in ida_remove()
1016 int offset = id % IDA_BITMAP_BITS; in ida_remove()
1052 WARN(1, "ida_remove called for id=%d which is not allocated.\n", id); in ida_remove()
1082 int ret, id; in ida_simple_get() local
1101 ret = ida_get_new_above(ida, start, &id); in ida_simple_get()
1103 if (id > max) { in ida_simple_get()
1104 ida_remove(ida, id); in ida_simple_get()
1107 ret = id; in ida_simple_get()
1124 void ida_simple_remove(struct ida *ida, unsigned int id) in ida_simple_remove() argument
1128 BUG_ON((int)id < 0); in ida_simple_remove()
1130 ida_remove(ida, id); in ida_simple_remove()