Lines Matching refs:idr
25 void item_idr_remove(struct idr *idr, int id) in item_idr_remove() argument
27 struct item *item = idr_find(idr, id); in item_idr_remove()
29 idr_remove(idr, id); in item_idr_remove()
36 DEFINE_IDR(idr); in idr_alloc_test()
38 assert(idr_alloc_cyclic(&idr, DUMMY_PTR, 0, 0x4000, GFP_KERNEL) == 0); in idr_alloc_test()
39 assert(idr_alloc_cyclic(&idr, DUMMY_PTR, 0x3ffd, 0x4000, GFP_KERNEL) == 0x3ffd); in idr_alloc_test()
40 idr_remove(&idr, 0x3ffd); in idr_alloc_test()
41 idr_remove(&idr, 0); in idr_alloc_test()
52 id = idr_alloc_cyclic(&idr, item, 1, 0x4000, GFP_KERNEL); in idr_alloc_test()
56 idr_for_each(&idr, item_idr_free, &idr); in idr_alloc_test()
57 idr_destroy(&idr); in idr_alloc_test()
62 DEFINE_IDR(idr); in idr_replace_test()
64 idr_alloc(&idr, (void *)-1, 10, 11, GFP_KERNEL); in idr_replace_test()
65 idr_replace(&idr, &idr, 10); in idr_replace_test()
67 idr_destroy(&idr); in idr_replace_test()
79 DEFINE_IDR(idr); in idr_null_test()
81 assert(idr_is_empty(&idr)); in idr_null_test()
83 assert(idr_alloc(&idr, NULL, 0, 0, GFP_KERNEL) == 0); in idr_null_test()
84 assert(!idr_is_empty(&idr)); in idr_null_test()
85 idr_remove(&idr, 0); in idr_null_test()
86 assert(idr_is_empty(&idr)); in idr_null_test()
88 assert(idr_alloc(&idr, NULL, 0, 0, GFP_KERNEL) == 0); in idr_null_test()
89 assert(!idr_is_empty(&idr)); in idr_null_test()
90 idr_destroy(&idr); in idr_null_test()
91 assert(idr_is_empty(&idr)); in idr_null_test()
94 assert(idr_alloc(&idr, NULL, 0, 0, GFP_KERNEL) == i); in idr_null_test()
97 assert(idr_replace(&idr, DUMMY_PTR, 3) == NULL); in idr_null_test()
98 assert(idr_replace(&idr, DUMMY_PTR, 4) == NULL); in idr_null_test()
99 assert(idr_replace(&idr, NULL, 4) == DUMMY_PTR); in idr_null_test()
100 assert(idr_replace(&idr, DUMMY_PTR, 11) == ERR_PTR(-ENOENT)); in idr_null_test()
101 idr_remove(&idr, 5); in idr_null_test()
102 assert(idr_alloc(&idr, NULL, 0, 0, GFP_KERNEL) == 5); in idr_null_test()
103 idr_remove(&idr, 5); in idr_null_test()
106 idr_remove(&idr, i); in idr_null_test()
107 assert(!idr_is_empty(&idr)); in idr_null_test()
109 idr_remove(&idr, 8); in idr_null_test()
110 assert(!idr_is_empty(&idr)); in idr_null_test()
111 idr_remove(&idr, 9); in idr_null_test()
112 assert(idr_is_empty(&idr)); in idr_null_test()
114 assert(idr_alloc(&idr, NULL, 0, 0, GFP_KERNEL) == 0); in idr_null_test()
115 assert(idr_replace(&idr, DUMMY_PTR, 3) == ERR_PTR(-ENOENT)); in idr_null_test()
116 assert(idr_replace(&idr, DUMMY_PTR, 0) == NULL); in idr_null_test()
117 assert(idr_replace(&idr, NULL, 0) == DUMMY_PTR); in idr_null_test()
119 idr_destroy(&idr); in idr_null_test()
120 assert(idr_is_empty(&idr)); in idr_null_test()
123 assert(idr_alloc(&idr, NULL, 1, 0, GFP_KERNEL) == i); in idr_null_test()
126 idr_destroy(&idr); in idr_null_test()
127 assert(idr_is_empty(&idr)); in idr_null_test()
133 DEFINE_IDR(idr); in idr_nowait_test()
139 assert(idr_alloc(&idr, item, i, i + 1, GFP_NOWAIT) == i); in idr_nowait_test()
144 idr_for_each(&idr, item_idr_free, &idr); in idr_nowait_test()
145 idr_destroy(&idr); in idr_nowait_test()
152 DEFINE_IDR(idr); in idr_get_next_test()
153 idr_init_base(&idr, base); in idr_get_next_test()
159 assert(idr_alloc(&idr, item, indices[i], indices[i+1], in idr_get_next_test()
164 idr_get_next(&idr, &nextid); in idr_get_next_test()
169 idr_for_each(&idr, item_idr_free, &idr); in idr_get_next_test()
170 idr_destroy(&idr); in idr_get_next_test()
180 void idr_u32_test1(struct idr *idr, u32 handle) in idr_u32_test1() argument
187 BUG_ON(idr_alloc_u32(idr, DUMMY_PTR, &id, id, GFP_KERNEL)); in idr_u32_test1()
189 BUG_ON(idr_alloc_u32(idr, DUMMY_PTR, &id, id, GFP_KERNEL) != -ENOSPC); in idr_u32_test1()
193 ptr = idr_get_next(idr, &sid); in idr_u32_test1()
201 idr_for_each(idr, idr_u32_cb, NULL); in idr_u32_test1()
206 BUG_ON(idr_remove(idr, id) != DUMMY_PTR); in idr_u32_test1()
207 BUG_ON(!idr_is_empty(idr)); in idr_u32_test1()
212 DEFINE_IDR(idr); in idr_u32_test()
213 idr_init_base(&idr, base); in idr_u32_test()
214 idr_u32_test1(&idr, 10); in idr_u32_test()
215 idr_u32_test1(&idr, 0x7fffffff); in idr_u32_test()
216 idr_u32_test1(&idr, 0x80000000); in idr_u32_test()
217 idr_u32_test1(&idr, 0x80000001); in idr_u32_test()
218 idr_u32_test1(&idr, 0xffe00000); in idr_u32_test()
219 idr_u32_test1(&idr, 0xffffffff); in idr_u32_test()
222 static void idr_align_test(struct idr *idr) in idr_align_test() argument
229 BUG_ON(idr_alloc(idr, &name[i], 0, 0, GFP_KERNEL) != i); in idr_align_test()
230 idr_for_each_entry(idr, entry, id); in idr_align_test()
232 idr_destroy(idr); in idr_align_test()
235 BUG_ON(idr_alloc(idr, &name[i], 0, 0, GFP_KERNEL) != i - 1); in idr_align_test()
236 idr_for_each_entry(idr, entry, id); in idr_align_test()
238 idr_destroy(idr); in idr_align_test()
241 BUG_ON(idr_alloc(idr, &name[i], 0, 0, GFP_KERNEL) != i - 2); in idr_align_test()
242 idr_for_each_entry(idr, entry, id); in idr_align_test()
244 idr_destroy(idr); in idr_align_test()
247 BUG_ON(idr_alloc(idr, &name[i], 0, 0, GFP_KERNEL) != i - 3); in idr_align_test()
248 idr_for_each_entry(idr, entry, id); in idr_align_test()
250 idr_destroy(idr); in idr_align_test()
253 BUG_ON(idr_alloc(idr, &name[i], 0, 0, GFP_KERNEL) != 0); in idr_align_test()
254 BUG_ON(idr_alloc(idr, &name[i + 1], 0, 0, GFP_KERNEL) != 1); in idr_align_test()
255 idr_for_each_entry(idr, entry, id); in idr_align_test()
256 idr_remove(idr, 1); in idr_align_test()
257 idr_for_each_entry(idr, entry, id); in idr_align_test()
258 idr_remove(idr, 0); in idr_align_test()
259 BUG_ON(!idr_is_empty(idr)); in idr_align_test()
263 BUG_ON(idr_alloc(idr, NULL, 0, 0, GFP_KERNEL) != 0); in idr_align_test()
264 idr_for_each_entry(idr, entry, id); in idr_align_test()
265 idr_replace(idr, &name[i], 0); in idr_align_test()
266 idr_for_each_entry(idr, entry, id); in idr_align_test()
267 BUG_ON(idr_find(idr, 0) != &name[i]); in idr_align_test()
268 idr_remove(idr, 0); in idr_align_test()
272 BUG_ON(idr_alloc(idr, &name[i], 0, 0, GFP_KERNEL) != 0); in idr_align_test()
273 BUG_ON(idr_alloc(idr, NULL, 0, 0, GFP_KERNEL) != 1); in idr_align_test()
274 idr_remove(idr, 1); in idr_align_test()
275 idr_for_each_entry(idr, entry, id); in idr_align_test()
276 idr_replace(idr, &name[i + 1], 0); in idr_align_test()
277 idr_for_each_entry(idr, entry, id); in idr_align_test()
278 idr_remove(idr, 0); in idr_align_test()
343 DEFINE_IDR(idr); in idr_checks()
347 assert(idr_alloc(&idr, item, 0, 20000, GFP_KERNEL) == i); in idr_checks()
350 assert(idr_alloc(&idr, DUMMY_PTR, 5, 30, GFP_KERNEL) < 0); in idr_checks()
353 item_idr_remove(&idr, i); in idr_checks()
355 idr_remove(&idr, 3); in idr_checks()
357 idr_for_each(&idr, item_idr_free, &idr); in idr_checks()
358 idr_destroy(&idr); in idr_checks()
360 assert(idr_is_empty(&idr)); in idr_checks()
362 idr_remove(&idr, 3); in idr_checks()
363 idr_remove(&idr, 0); in idr_checks()
365 assert(idr_alloc(&idr, DUMMY_PTR, 0, 0, GFP_KERNEL) == 0); in idr_checks()
366 idr_remove(&idr, 1); in idr_checks()
368 assert(idr_alloc(&idr, DUMMY_PTR, 0, 0, GFP_KERNEL) == i); in idr_checks()
369 idr_remove(&idr, 1 << 30); in idr_checks()
370 idr_destroy(&idr); in idr_checks()
374 assert(idr_alloc(&idr, item, i, i + 10, GFP_KERNEL) == i); in idr_checks()
376 assert(idr_alloc(&idr, DUMMY_PTR, i - 2, i, GFP_KERNEL) == -ENOSPC); in idr_checks()
377 assert(idr_alloc(&idr, DUMMY_PTR, i - 2, i + 10, GFP_KERNEL) == -ENOSPC); in idr_checks()
379 idr_for_each(&idr, item_idr_free, &idr); in idr_checks()
380 idr_destroy(&idr); in idr_checks()
381 idr_destroy(&idr); in idr_checks()
383 assert(idr_is_empty(&idr)); in idr_checks()
385 idr_set_cursor(&idr, INT_MAX - 3UL); in idr_checks()
394 id = idr_alloc_cyclic(&idr, item, 0, 0, GFP_KERNEL); in idr_checks()
398 idr_for_each(&idr, item_idr_free, &idr); in idr_checks()
399 idr_destroy(&idr); in idr_checks()
400 assert(idr_is_empty(&idr)); in idr_checks()
404 assert(idr_alloc(&idr, item, 1, 20000, GFP_KERNEL) == i); in idr_checks()
407 idr_for_each(&idr, item_idr_free, &idr); in idr_checks()
408 idr_destroy(&idr); in idr_checks()
420 idr_align_test(&idr); in idr_checks()