diff options
author | Tejun Heo <tj@kernel.org> | 2013-03-13 17:59:42 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-03-13 18:21:47 -0400 |
commit | c8615d3716fe327c2540cf514a34b227dc9b39e8 (patch) | |
tree | 2ad264bec1623c7b0cf43998b74654dd627a6e24 | |
parent | 8e467e855ca5ed2921f290655f96ac40d5dc571c (diff) |
idr: deprecate idr_pre_get() and idr_get_new[_above]()
Now that all in-kernel users are converted to ues the new alloc
interface, mark the old interface deprecated. We should be able to
remove these in a few releases.
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | include/linux/idr.h | 66 | ||||
-rw-r--r-- | lib/idr.c | 41 |
2 files changed, 55 insertions, 52 deletions
diff --git a/include/linux/idr.h b/include/linux/idr.h index 8c1f81f823c8..2640c7e99e51 100644 --- a/include/linux/idr.h +++ b/include/linux/idr.h | |||
@@ -73,8 +73,6 @@ struct idr { | |||
73 | */ | 73 | */ |
74 | 74 | ||
75 | void *idr_find_slowpath(struct idr *idp, int id); | 75 | void *idr_find_slowpath(struct idr *idp, int id); |
76 | int idr_pre_get(struct idr *idp, gfp_t gfp_mask); | ||
77 | int idr_get_new_above(struct idr *idp, void *ptr, int starting_id, int *id); | ||
78 | void idr_preload(gfp_t gfp_mask); | 76 | void idr_preload(gfp_t gfp_mask); |
79 | int idr_alloc(struct idr *idp, void *ptr, int start, int end, gfp_t gfp_mask); | 77 | int idr_alloc(struct idr *idp, void *ptr, int start, int end, gfp_t gfp_mask); |
80 | int idr_for_each(struct idr *idp, | 78 | int idr_for_each(struct idr *idp, |
@@ -120,19 +118,6 @@ static inline void *idr_find(struct idr *idr, int id) | |||
120 | } | 118 | } |
121 | 119 | ||
122 | /** | 120 | /** |
123 | * idr_get_new - allocate new idr entry | ||
124 | * @idp: idr handle | ||
125 | * @ptr: pointer you want associated with the id | ||
126 | * @id: pointer to the allocated handle | ||
127 | * | ||
128 | * Simple wrapper around idr_get_new_above() w/ @starting_id of zero. | ||
129 | */ | ||
130 | static inline int idr_get_new(struct idr *idp, void *ptr, int *id) | ||
131 | { | ||
132 | return idr_get_new_above(idp, ptr, 0, id); | ||
133 | } | ||
134 | |||
135 | /** | ||
136 | * idr_for_each_entry - iterate over an idr's elements of a given type | 121 | * idr_for_each_entry - iterate over an idr's elements of a given type |
137 | * @idp: idr handle | 122 | * @idp: idr handle |
138 | * @entry: the type * to use as cursor | 123 | * @entry: the type * to use as cursor |
@@ -143,7 +128,56 @@ static inline int idr_get_new(struct idr *idp, void *ptr, int *id) | |||
143 | entry != NULL; \ | 128 | entry != NULL; \ |
144 | ++id, entry = (typeof(entry))idr_get_next((idp), &(id))) | 129 | ++id, entry = (typeof(entry))idr_get_next((idp), &(id))) |
145 | 130 | ||
146 | void __idr_remove_all(struct idr *idp); /* don't use */ | 131 | /* |
132 | * Don't use the following functions. These exist only to suppress | ||
133 | * deprecated warnings on EXPORT_SYMBOL()s. | ||
134 | */ | ||
135 | int __idr_pre_get(struct idr *idp, gfp_t gfp_mask); | ||
136 | int __idr_get_new_above(struct idr *idp, void *ptr, int starting_id, int *id); | ||
137 | void __idr_remove_all(struct idr *idp); | ||
138 | |||
139 | /** | ||
140 | * idr_pre_get - reserve resources for idr allocation | ||
141 | * @idp: idr handle | ||
142 | * @gfp_mask: memory allocation flags | ||
143 | * | ||
144 | * Part of old alloc interface. This is going away. Use | ||
145 | * idr_preload[_end]() and idr_alloc() instead. | ||
146 | */ | ||
147 | static inline int __deprecated idr_pre_get(struct idr *idp, gfp_t gfp_mask) | ||
148 | { | ||
149 | return __idr_pre_get(idp, gfp_mask); | ||
150 | } | ||
151 | |||
152 | /** | ||
153 | * idr_get_new_above - allocate new idr entry above or equal to a start id | ||
154 | * @idp: idr handle | ||
155 | * @ptr: pointer you want associated with the id | ||
156 | * @starting_id: id to start search at | ||
157 | * @id: pointer to the allocated handle | ||
158 | * | ||
159 | * Part of old alloc interface. This is going away. Use | ||
160 | * idr_preload[_end]() and idr_alloc() instead. | ||
161 | */ | ||
162 | static inline int __deprecated idr_get_new_above(struct idr *idp, void *ptr, | ||
163 | int starting_id, int *id) | ||
164 | { | ||
165 | return __idr_get_new_above(idp, ptr, starting_id, id); | ||
166 | } | ||
167 | |||
168 | /** | ||
169 | * idr_get_new - allocate new idr entry | ||
170 | * @idp: idr handle | ||
171 | * @ptr: pointer you want associated with the id | ||
172 | * @id: pointer to the allocated handle | ||
173 | * | ||
174 | * Part of old alloc interface. This is going away. Use | ||
175 | * idr_preload[_end]() and idr_alloc() instead. | ||
176 | */ | ||
177 | static inline int __deprecated idr_get_new(struct idr *idp, void *ptr, int *id) | ||
178 | { | ||
179 | return __idr_get_new_above(idp, ptr, 0, id); | ||
180 | } | ||
147 | 181 | ||
148 | /** | 182 | /** |
149 | * idr_remove_all - remove all ids from the given idr tree | 183 | * idr_remove_all - remove all ids from the given idr tree |
@@ -184,20 +184,7 @@ static void idr_mark_full(struct idr_layer **pa, int id) | |||
184 | } | 184 | } |
185 | } | 185 | } |
186 | 186 | ||
187 | /** | 187 | int __idr_pre_get(struct idr *idp, gfp_t gfp_mask) |
188 | * idr_pre_get - reserve resources for idr allocation | ||
189 | * @idp: idr handle | ||
190 | * @gfp_mask: memory allocation flags | ||
191 | * | ||
192 | * This function should be called prior to calling the idr_get_new* functions. | ||
193 | * It preallocates enough memory to satisfy the worst possible allocation. The | ||
194 | * caller should pass in GFP_KERNEL if possible. This of course requires that | ||
195 | * no spinning locks be held. | ||
196 | * | ||
197 | * If the system is REALLY out of memory this function returns %0, | ||
198 | * otherwise %1. | ||
199 | */ | ||
200 | int idr_pre_get(struct idr *idp, gfp_t gfp_mask) | ||
201 | { | 188 | { |
202 | while (idp->id_free_cnt < MAX_IDR_FREE) { | 189 | while (idp->id_free_cnt < MAX_IDR_FREE) { |
203 | struct idr_layer *new; | 190 | struct idr_layer *new; |
@@ -208,7 +195,7 @@ int idr_pre_get(struct idr *idp, gfp_t gfp_mask) | |||
208 | } | 195 | } |
209 | return 1; | 196 | return 1; |
210 | } | 197 | } |
211 | EXPORT_SYMBOL(idr_pre_get); | 198 | EXPORT_SYMBOL(__idr_pre_get); |
212 | 199 | ||
213 | /** | 200 | /** |
214 | * sub_alloc - try to allocate an id without growing the tree depth | 201 | * sub_alloc - try to allocate an id without growing the tree depth |
@@ -375,25 +362,7 @@ static void idr_fill_slot(struct idr *idr, void *ptr, int id, | |||
375 | idr_mark_full(pa, id); | 362 | idr_mark_full(pa, id); |
376 | } | 363 | } |
377 | 364 | ||
378 | /** | 365 | int __idr_get_new_above(struct idr *idp, void *ptr, int starting_id, int *id) |
379 | * idr_get_new_above - allocate new idr entry above or equal to a start id | ||
380 | * @idp: idr handle | ||
381 | * @ptr: pointer you want associated with the id | ||
382 | * @starting_id: id to start search at | ||
383 | * @id: pointer to the allocated handle | ||
384 | * | ||
385 | * This is the allocate id function. It should be called with any | ||
386 | * required locks. | ||
387 | * | ||
388 | * If allocation from IDR's private freelist fails, idr_get_new_above() will | ||
389 | * return %-EAGAIN. The caller should retry the idr_pre_get() call to refill | ||
390 | * IDR's preallocation and then retry the idr_get_new_above() call. | ||
391 | * | ||
392 | * If the idr is full idr_get_new_above() will return %-ENOSPC. | ||
393 | * | ||
394 | * @id returns a value in the range @starting_id ... %0x7fffffff | ||
395 | */ | ||
396 | int idr_get_new_above(struct idr *idp, void *ptr, int starting_id, int *id) | ||
397 | { | 366 | { |
398 | struct idr_layer *pa[MAX_IDR_LEVEL + 1]; | 367 | struct idr_layer *pa[MAX_IDR_LEVEL + 1]; |
399 | int rv; | 368 | int rv; |
@@ -406,7 +375,7 @@ int idr_get_new_above(struct idr *idp, void *ptr, int starting_id, int *id) | |||
406 | *id = rv; | 375 | *id = rv; |
407 | return 0; | 376 | return 0; |
408 | } | 377 | } |
409 | EXPORT_SYMBOL(idr_get_new_above); | 378 | EXPORT_SYMBOL(__idr_get_new_above); |
410 | 379 | ||
411 | /** | 380 | /** |
412 | * idr_preload - preload for idr_alloc() | 381 | * idr_preload - preload for idr_alloc() |
@@ -907,7 +876,7 @@ static void free_bitmap(struct ida *ida, struct ida_bitmap *bitmap) | |||
907 | int ida_pre_get(struct ida *ida, gfp_t gfp_mask) | 876 | int ida_pre_get(struct ida *ida, gfp_t gfp_mask) |
908 | { | 877 | { |
909 | /* allocate idr_layers */ | 878 | /* allocate idr_layers */ |
910 | if (!idr_pre_get(&ida->idr, gfp_mask)) | 879 | if (!__idr_pre_get(&ida->idr, gfp_mask)) |
911 | return 0; | 880 | return 0; |
912 | 881 | ||
913 | /* allocate free_bitmap */ | 882 | /* allocate free_bitmap */ |