On Tue, 11 Mar 2008 21:27:30 +0900
"Akinobu Mita" <akinobu.mita@gmail.com> wrote:
Of course it can be used in those places. Here's the idr.c conversion:
--- a/lib/idr.c~a
+++ a/lib/idr.c
@@ -585,14 +585,6 @@ static void idr_cache_ctor(struct kmem_c
memset(idr_layer, 0, sizeof(struct idr_layer));
}
-static int init_id_cache(void)
-{
- if (!idr_layer_cache)
- idr_layer_cache = kmem_cache_create("idr_layer_cache",
- sizeof(struct idr_layer), 0, 0, idr_cache_ctor);
- return 0;
-}
-
/**
* idr_init - initialize idr handle
* @idp: idr handle
@@ -602,7 +594,9 @@ static int init_id_cache(void)
*/
void idr_init(struct idr *idp)
{
- init_id_cache();
+ if (ONCE())
+ idr_layer_cache = kmem_cache_create("idr_layer_cache",
+ sizeof(struct idr_layer), 0, 0, idr_cache_ctor);
memset(idp, 0, sizeof(struct idr));
spin_lock_init(&idp->lock);
}
--