@@ -198,22 +198,15 @@ int tifm_add_adapter(struct tifm_adapter *fm)
{
int rc;
- idr_preload(GFP_KERNEL);
- spin_lock(&tifm_adapter_lock);
- rc = idr_alloc(&tifm_adapter_idr, fm, 0, 0, GFP_NOWAIT);
- if (rc >= 0)
- fm->id = rc;
- spin_unlock(&tifm_adapter_lock);
- idr_preload_end();
+ rc = idr_get_index(&tifm_adapter_idr, &tifm_adapter_lock, fm);
if (rc < 0)
return rc;
+ fm->id = rc;
dev_set_name(&fm->dev, "tifm%u", fm->id);
rc = device_add(&fm->dev);
if (rc) {
- spin_lock(&tifm_adapter_lock);
- idr_remove(&tifm_adapter_idr, fm->id);
- spin_unlock(&tifm_adapter_lock);
+ idr_put_index(&tifm_adapter_idr, &tifm_adapter_lock, fm->id);
}
return rc;
@@ -230,9 +223,7 @@ void tifm_remove_adapter(struct tifm_adapter *fm)
device_unregister(&fm->sockets[cnt]->dev);
}
- spin_lock(&tifm_adapter_lock);
- idr_remove(&tifm_adapter_idr, fm->id);
- spin_unlock(&tifm_adapter_lock);
+ idr_put_index(&tifm_adapter_idr, &tifm_adapter_lock, fm->id);
device_del(&fm->dev);
}
EXPORT_SYMBOL(tifm_remove_adapter);
Signed-off-by: Lee Duncan <lduncan@suse.com> --- drivers/misc/tifm_core.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-)