• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /freebsd-13-stable/sys/compat/linuxkpi/common/src/

Lines Matching refs:idr

46 #include <linux/idr.h>
67 static MALLOC_DEFINE(M_IDR, "idr", "Linux IDR compat");
160 idr_max(struct idr *idr)
162 return (1 << (idr->layers * IDR_BITS)) - 1;
172 idr_init(struct idr *idr)
174 bzero(idr, sizeof(*idr));
175 mtx_init(&idr->lock, "idr", NULL, MTX_DEF);
180 idr_destroy(struct idr *idr)
184 idr_remove_all(idr);
185 mtx_lock(&idr->lock);
186 for (il = idr->free; il != NULL; il = iln) {
190 mtx_unlock(&idr->lock);
191 mtx_destroy(&idr->lock);
211 idr_remove_all(struct idr *idr)
214 mtx_lock(&idr->lock);
215 idr_remove_layer(idr->top, idr->layers - 1);
216 idr->top = NULL;
217 idr->layers = 0;
218 mtx_unlock(&idr->lock);
222 idr_remove_locked(struct idr *idr, int id)
230 il = idr->top;
231 layer = idr->layers - 1;
232 if (il == NULL || id > idr_max(idr))
252 id, idr, il);
261 idr_remove(struct idr *idr, int id)
265 mtx_lock(&idr->lock);
266 res = idr_remove_locked(idr, id);
267 mtx_unlock(&idr->lock);
273 idr_find_layer_locked(struct idr *idr, int id)
279 il = idr->top;
280 layer = idr->layers - 1;
281 if (il == NULL || id > idr_max(idr))
291 idr_replace(struct idr *idr, void *ptr, int id)
297 mtx_lock(&idr->lock);
298 il = idr_find_layer_locked(idr, id);
308 mtx_unlock(&idr->lock);
313 idr_find_locked(struct idr *idr, int id)
318 mtx_assert(&idr->lock, MA_OWNED);
319 il = idr_find_layer_locked(idr, id);
328 idr_find(struct idr *idr, int id)
332 mtx_lock(&idr->lock);
333 res = idr_find_locked(idr, id);
334 mtx_unlock(&idr->lock);
339 idr_get_next(struct idr *idr, int *nextidp)
344 mtx_lock(&idr->lock);
345 for (; id <= idr_max(idr); id++) {
346 res = idr_find_locked(idr, id);
352 mtx_unlock(&idr->lock);
357 idr_pre_get(struct idr *idr, gfp_t gfp_mask)
363 mtx_lock(&idr->lock);
365 need = idr->layers + 1;
366 for (il = idr->free; il != NULL; il = il->ary[0])
368 mtx_unlock(&idr->lock);
384 mtx_lock(&idr->lock);
385 il->ary[0] = idr->free;
386 idr->free = head;
392 idr_free_list_get(struct idr *idp)
404 idr_get(struct idr *idp)
421 * Could be implemented as get_new_above(idr, ptr, 0, idp) but written
425 idr_get_new_locked(struct idr *idr, void *ptr, int *idp)
434 mtx_assert(&idr->lock, MA_OWNED);
440 if (idr->top == NULL || idr->top->bitmap == 0) {
441 if (idr->layers == MAX_LEVEL + 1) {
445 il = idr_get(idr);
448 il->ary[0] = idr->top;
449 if (idr->top)
451 idr->top = il;
452 idr->layers++;
454 il = idr->top;
459 for (layer = idr->layers - 1;; layer--) {
464 idr, il);
470 il->ary[idx] = idr_get(idr);
485 while (il->bitmap == 0 && ++layer < idr->layers) {
492 if (error == 0 && idr_find_locked(idr, id) != ptr) {
493 panic("idr_get_new: Failed for idr %p, id %d, ptr %p\n",
494 idr, id, ptr);
501 idr_get_new(struct idr *idr, void *ptr, int *idp)
505 mtx_lock(&idr->lock);
506 retval = idr_get_new_locked(idr, ptr, idp);
507 mtx_unlock(&idr->lock);
512 idr_get_new_above_locked(struct idr *idr, void *ptr, int starting_id, int *idp)
521 mtx_assert(&idr->lock, MA_OWNED);
542 while (idr->layers <= layer ||
543 idr->top->bitmap < (1 << idr_pos(starting_id, idr->layers - 1))) {
544 if (idr->layers == MAX_LEVEL + 1) {
548 il = idr_get(idr);
551 il->ary[0] = idr->top;
552 if (idr->top && idr->top->bitmap == 0)
554 idr->top = il;
555 idr->layers++;
557 il = idr->top;
562 for (layer = idr->layers - 1;; layer--) {
569 idr, il);
588 il->ary[idx] = idr_get(idr);
603 while (il->bitmap == 0 && ++layer < idr->layers) {
610 if (error == 0 && idr_find_locked(idr, id) != ptr) {
611 panic("idr_get_new_above: Failed for idr %p, id %d, ptr %p\n",
612 idr, id, ptr);
619 idr_get_new_above(struct idr *idr, void *ptr, int starting_id, int *idp)
623 mtx_lock(&idr->lock);
624 retval = idr_get_new_above_locked(idr, ptr, starting_id, idp);
625 mtx_unlock(&idr->lock);
632 return (idr_get_new_above(&ida->idr, NULL, starting_id, p_id));
636 idr_alloc_locked(struct idr *idr, void *ptr, int start, int end)
642 mtx_assert(&idr->lock, MA_OWNED);
650 error = idr_get_new_locked(idr, ptr, &id);
652 error = idr_get_new_above_locked(idr, ptr, start, &id);
657 idr_remove_locked(idr, id);
664 idr_alloc(struct idr *idr, void *ptr, int start, int end, gfp_t gfp_mask)
668 mtx_lock(&idr->lock);
669 retval = idr_alloc_locked(idr, ptr, start, end);
670 mtx_unlock(&idr->lock);
675 idr_alloc_cyclic(struct idr *idr, void *ptr, int start, int end, gfp_t gfp_mask)
679 mtx_lock(&idr->lock);
680 retval = idr_alloc_locked(idr, ptr, max(start, idr->next_cyclic_id), end);
682 retval = idr_alloc_locked(idr, ptr, start, end);
684 idr->next_cyclic_id = retval + 1;
685 mtx_unlock(&idr->lock);
720 idr_for_each(struct idr *idp, int (*f)(int id, void *p, void *data), void *data)
733 idr_is_empty(struct idr *idp)
742 if (idr_pre_get(&ida->idr, flags) == 0)
789 idr_remove(&ida->idr, id);
795 idr_remove(&ida->idr, id);
801 idr_init(&ida->idr);
807 idr_destroy(&ida->idr);