diff options
Diffstat (limited to 'lib/idr.c')
-rw-r--r-- | lib/idr.c | 37 |
1 files changed, 20 insertions, 17 deletions
@@ -110,9 +110,10 @@ static void idr_mark_full(struct idr_layer **pa, int id) | |||
110 | * @idp: idr handle | 110 | * @idp: idr handle |
111 | * @gfp_mask: memory allocation flags | 111 | * @gfp_mask: memory allocation flags |
112 | * | 112 | * |
113 | * This function should be called prior to locking and calling the | 113 | * This function should be called prior to calling the idr_get_new* functions. |
114 | * idr_get_new* functions. It preallocates enough memory to satisfy | 114 | * It preallocates enough memory to satisfy the worst possible allocation. The |
115 | * the worst possible allocation. | 115 | * caller should pass in GFP_KERNEL if possible. This of course requires that |
116 | * no spinning locks be held. | ||
116 | * | 117 | * |
117 | * If the system is REALLY out of memory this function returns 0, | 118 | * If the system is REALLY out of memory this function returns 0, |
118 | * otherwise 1. | 119 | * otherwise 1. |
@@ -284,15 +285,17 @@ static int idr_get_new_above_int(struct idr *idp, void *ptr, int starting_id) | |||
284 | * idr_get_new_above - allocate new idr entry above or equal to a start id | 285 | * idr_get_new_above - allocate new idr entry above or equal to a start id |
285 | * @idp: idr handle | 286 | * @idp: idr handle |
286 | * @ptr: pointer you want associated with the id | 287 | * @ptr: pointer you want associated with the id |
287 | * @start_id: id to start search at | 288 | * @starting_id: id to start search at |
288 | * @id: pointer to the allocated handle | 289 | * @id: pointer to the allocated handle |
289 | * | 290 | * |
290 | * This is the allocate id function. It should be called with any | 291 | * This is the allocate id function. It should be called with any |
291 | * required locks. | 292 | * required locks. |
292 | * | 293 | * |
293 | * If memory is required, it will return -EAGAIN, you should unlock | 294 | * If allocation from IDR's private freelist fails, idr_get_new_above() will |
294 | * and go back to the idr_pre_get() call. If the idr is full, it will | 295 | * return -EAGAIN. The caller should retry the idr_pre_get() call to refill |
295 | * return -ENOSPC. | 296 | * IDR's preallocation and then retry the idr_get_new_above() call. |
297 | * | ||
298 | * If the idr is full idr_get_new_above() will return -ENOSPC. | ||
296 | * | 299 | * |
297 | * @id returns a value in the range @starting_id ... 0x7fffffff | 300 | * @id returns a value in the range @starting_id ... 0x7fffffff |
298 | */ | 301 | */ |
@@ -318,12 +321,11 @@ EXPORT_SYMBOL(idr_get_new_above); | |||
318 | * @ptr: pointer you want associated with the id | 321 | * @ptr: pointer you want associated with the id |
319 | * @id: pointer to the allocated handle | 322 | * @id: pointer to the allocated handle |
320 | * | 323 | * |
321 | * This is the allocate id function. It should be called with any | 324 | * If allocation from IDR's private freelist fails, idr_get_new_above() will |
322 | * required locks. | 325 | * return -EAGAIN. The caller should retry the idr_pre_get() call to refill |
326 | * IDR's preallocation and then retry the idr_get_new_above() call. | ||
323 | * | 327 | * |
324 | * If memory is required, it will return -EAGAIN, you should unlock | 328 | * If the idr is full idr_get_new_above() will return -ENOSPC. |
325 | * and go back to the idr_pre_get() call. If the idr is full, it will | ||
326 | * return -ENOSPC. | ||
327 | * | 329 | * |
328 | * @id returns a value in the range 0 ... 0x7fffffff | 330 | * @id returns a value in the range 0 ... 0x7fffffff |
329 | */ | 331 | */ |
@@ -479,7 +481,7 @@ EXPORT_SYMBOL(idr_remove_all); | |||
479 | 481 | ||
480 | /** | 482 | /** |
481 | * idr_destroy - release all cached layers within an idr tree | 483 | * idr_destroy - release all cached layers within an idr tree |
482 | * idp: idr handle | 484 | * @idp: idr handle |
483 | */ | 485 | */ |
484 | void idr_destroy(struct idr *idp) | 486 | void idr_destroy(struct idr *idp) |
485 | { | 487 | { |
@@ -586,10 +588,11 @@ EXPORT_SYMBOL(idr_for_each); | |||
586 | /** | 588 | /** |
587 | * idr_get_next - lookup next object of id to given id. | 589 | * idr_get_next - lookup next object of id to given id. |
588 | * @idp: idr handle | 590 | * @idp: idr handle |
589 | * @id: pointer to lookup key | 591 | * @nextidp: pointer to lookup key |
590 | * | 592 | * |
591 | * Returns pointer to registered object with id, which is next number to | 593 | * Returns pointer to registered object with id, which is next number to |
592 | * given id. | 594 | * given id. After being looked up, *@nextidp will be updated for the next |
595 | * iteration. | ||
593 | */ | 596 | */ |
594 | 597 | ||
595 | void *idr_get_next(struct idr *idp, int *nextidp) | 598 | void *idr_get_next(struct idr *idp, int *nextidp) |
@@ -758,7 +761,7 @@ EXPORT_SYMBOL(ida_pre_get); | |||
758 | /** | 761 | /** |
759 | * ida_get_new_above - allocate new ID above or equal to a start id | 762 | * ida_get_new_above - allocate new ID above or equal to a start id |
760 | * @ida: ida handle | 763 | * @ida: ida handle |
761 | * @staring_id: id to start search at | 764 | * @starting_id: id to start search at |
762 | * @p_id: pointer to the allocated handle | 765 | * @p_id: pointer to the allocated handle |
763 | * | 766 | * |
764 | * Allocate new ID above or equal to @ida. It should be called with | 767 | * Allocate new ID above or equal to @ida. It should be called with |
@@ -912,7 +915,7 @@ EXPORT_SYMBOL(ida_remove); | |||
912 | 915 | ||
913 | /** | 916 | /** |
914 | * ida_destroy - release all cached layers within an ida tree | 917 | * ida_destroy - release all cached layers within an ida tree |
915 | * ida: ida handle | 918 | * @ida: ida handle |
916 | */ | 919 | */ |
917 | void ida_destroy(struct ida *ida) | 920 | void ida_destroy(struct ida *ida) |
918 | { | 921 | { |