X-Git-Url: https://git.kernelconcepts.de/?a=blobdiff_plain;f=lib%2Fidr.c;h=6414b2fb482d48255e0e54e23dcead7ee849658c;hb=005a5a06a6dd13a0ca3f2c6a0218e8d94ed36d8a;hp=6415d053e2bfa838e3a95313137d07a944261fd8;hpb=b946ecbb11145ae2f375d2d7289a6e7280462b02;p=karo-tx-linux.git diff --git a/lib/idr.c b/lib/idr.c index 6415d053e2bf..6414b2fb482d 100644 --- a/lib/idr.c +++ b/lib/idr.c @@ -72,7 +72,7 @@ static void free_layer(struct idr *idp, struct idr_layer *p) * If the system is REALLY out of memory this function returns 0, * otherwise 1. */ -int idr_pre_get(struct idr *idp, unsigned gfp_mask) +int idr_pre_get(struct idr *idp, gfp_t gfp_mask) { while (idp->id_free_cnt < IDR_FREE_MAX) { struct idr_layer *new; @@ -345,6 +345,19 @@ void idr_remove(struct idr *idp, int id) } EXPORT_SYMBOL(idr_remove); +/** + * idr_destroy - release all cached layers within an idr tree + * idp: idr handle + */ +void idr_destroy(struct idr *idp) +{ + while (idp->id_free_cnt) { + struct idr_layer *p = alloc_layer(idp); + kmem_cache_free(idr_layer_cache, p); + } +} +EXPORT_SYMBOL(idr_destroy); + /** * idr_find - return pointer for given id * @idp: idr handle