Lines Matching refs:id
172 static void idr_mark_full(struct idr_layer **pa, int id) in idr_mark_full() argument
177 __set_bit(id & IDR_MASK, p->bitmap); in idr_mark_full()
187 id = id >> IDR_BITS; in idr_mark_full()
188 __set_bit((id & IDR_MASK), p->bitmap); in idr_mark_full()
225 int l, id, oid; in sub_alloc() local
227 id = *starting_id; in sub_alloc()
236 n = (id >> (IDR_BITS*l)) & IDR_MASK; in sub_alloc()
241 oid = id; in sub_alloc()
242 id = (id | ((1 << (IDR_BITS * l)) - 1)) + 1; in sub_alloc()
245 if (id > idr_max(idp->layers)) { in sub_alloc()
246 *starting_id = id; in sub_alloc()
256 if (oid >> sh == id >> sh) in sub_alloc()
263 id = ((id >> sh) ^ n ^ m) << sh; in sub_alloc()
265 if ((id >= MAX_IDR_BIT) || (id < 0)) in sub_alloc()
277 new->prefix = id & idr_layer_prefix_mask(new->layer); in sub_alloc()
286 return id; in sub_alloc()
294 int layers, v, id; in idr_get_empty_slot() local
297 id = starting_id; in idr_get_empty_slot()
311 while (id > idr_max(layers)) { in idr_get_empty_slot()
341 new->prefix = id & idr_layer_prefix_mask(new->layer); in idr_get_empty_slot()
348 v = sub_alloc(idp, &id, pa, gfp_mask, layer_idr); in idr_get_empty_slot()
358 static void idr_fill_slot(struct idr *idr, void *ptr, int id, in idr_fill_slot() argument
364 rcu_assign_pointer(pa[0]->ary[id & IDR_MASK], (struct idr_layer *)ptr); in idr_fill_slot()
366 idr_mark_full(pa, id); in idr_fill_slot()
454 int id; in idr_alloc() local
465 id = idr_get_empty_slot(idr, start, pa, gfp_mask, NULL); in idr_alloc()
466 if (unlikely(id < 0)) in idr_alloc()
467 return id; in idr_alloc()
468 if (unlikely(id > max)) in idr_alloc()
471 idr_fill_slot(idr, ptr, id, pa); in idr_alloc()
472 return id; in idr_alloc()
491 int id; in idr_alloc_cyclic() local
493 id = idr_alloc(idr, ptr, max(start, idr->cur), end, gfp_mask); in idr_alloc_cyclic()
494 if (id == -ENOSPC) in idr_alloc_cyclic()
495 id = idr_alloc(idr, ptr, start, end, gfp_mask); in idr_alloc_cyclic()
497 if (likely(id >= 0)) in idr_alloc_cyclic()
498 idr->cur = id + 1; in idr_alloc_cyclic()
499 return id; in idr_alloc_cyclic()
503 static void idr_remove_warning(int id) in idr_remove_warning() argument
505 WARN(1, "idr_remove called for id=%d which is not allocated.\n", id); in idr_remove_warning()
508 static void sub_remove(struct idr *idp, int shift, int id) in sub_remove() argument
520 n = (id >> shift) & IDR_MASK; in sub_remove()
526 n = id & IDR_MASK; in sub_remove()
542 idr_remove_warning(id); in sub_remove()
550 void idr_remove(struct idr *idp, int id) in idr_remove() argument
555 if (id < 0) in idr_remove()
558 if (id > idr_max(idp->layers)) { in idr_remove()
559 idr_remove_warning(id); in idr_remove()
563 sub_remove(idp, (idp->layers - 1) * IDR_BITS, id); in idr_remove()
585 int n, id, max; in __idr_remove_all() local
596 id = 0; in __idr_remove_all()
597 while (id >= 0 && id <= max) { in __idr_remove_all()
601 p = p->ary[(id >> n) & IDR_MASK]; in __idr_remove_all()
605 bt_mask = id; in __idr_remove_all()
606 id += 1 << n; in __idr_remove_all()
608 while (n < fls(id ^ bt_mask)) { in __idr_remove_all()
642 void *idr_find_slowpath(struct idr *idp, int id) in idr_find_slowpath() argument
647 if (id < 0) in idr_find_slowpath()
655 if (id > idr_max(p->layer + 1)) in idr_find_slowpath()
662 p = rcu_dereference_raw(p->ary[(id >> n) & IDR_MASK]); in idr_find_slowpath()
687 int (*fn)(int id, void *p, void *data), void *data) in idr_for_each() argument
689 int n, id, max, error = 0; in idr_for_each() local
698 id = 0; in idr_for_each()
699 while (id >= 0 && id <= max) { in idr_for_each()
703 p = rcu_dereference_raw(p->ary[(id >> n) & IDR_MASK]); in idr_for_each()
708 error = fn(id, (void *)p, data); in idr_for_each()
713 id += 1 << n; in idr_for_each()
714 while (n < fls(id)) { in idr_for_each()
740 int id = *nextidp; in idr_get_next() local
750 while (id >= 0 && id <= max) { in idr_get_next()
754 p = rcu_dereference_raw(p->ary[(id >> n) & IDR_MASK]); in idr_get_next()
759 *nextidp = id; in idr_get_next()
770 id = round_up(id + 1, 1 << n); in idr_get_next()
771 while (n < fls(id)) { in idr_get_next()
793 void *idr_replace(struct idr *idp, void *ptr, int id) in idr_replace() argument
798 if (id < 0) in idr_replace()
805 if (id > idr_max(p->layer + 1)) in idr_replace()
810 p = p->ary[(id >> n) & IDR_MASK]; in idr_replace()
814 n = id & IDR_MASK; in idr_replace()
845 static int idr_has_entry(int id, void *p, void *data) in idr_has_entry() argument
939 int t, id; in ida_get_new_above() local
980 id = idr_id * IDA_BITMAP_BITS + t; in ida_get_new_above()
981 if (id >= MAX_IDR_BIT) in ida_get_new_above()
988 *p_id = id; in ida_get_new_above()
1010 void ida_remove(struct ida *ida, int id) in ida_remove() argument
1014 int idr_id = id / IDA_BITMAP_BITS; in ida_remove()
1015 int offset = id % IDA_BITMAP_BITS; in ida_remove()
1051 WARN(1, "ida_remove called for id=%d which is not allocated.\n", id); in ida_remove()
1081 int ret, id; in ida_simple_get() local
1100 ret = ida_get_new_above(ida, start, &id); in ida_simple_get()
1102 if (id > max) { in ida_simple_get()
1103 ida_remove(ida, id); in ida_simple_get()
1106 ret = id; in ida_simple_get()
1123 void ida_simple_remove(struct ida *ida, unsigned int id) in ida_simple_remove() argument
1127 BUG_ON((int)id < 0); in ida_simple_remove()
1129 ida_remove(ida, id); in ida_simple_remove()