From: Matthew Wilcox Date: Tue, 12 Feb 2019 21:20:07 +0000 (-0500) Subject: tifm: Convert to IDA X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=4511190e00023efa6fa3a1e40e66dff954baf724;p=users%2Fwilly%2Fxarray.git tifm: Convert to IDA Signed-off-by: Matthew Wilcox --- diff --git a/drivers/misc/tifm_core.c b/drivers/misc/tifm_core.c index 667e574a7df2..3dd00f072b99 100644 --- a/drivers/misc/tifm_core.c +++ b/drivers/misc/tifm_core.c @@ -15,8 +15,7 @@ #define DRIVER_VERSION "0.8" static struct workqueue_struct *workqueue; -static DEFINE_IDR(tifm_adapter_idr); -static DEFINE_SPINLOCK(tifm_adapter_lock); +static DEFINE_IDA(tifm_adapter_ids); static const char *tifm_media_type_name(unsigned char type, unsigned char nt) { @@ -192,25 +191,15 @@ EXPORT_SYMBOL(tifm_alloc_adapter); int tifm_add_adapter(struct tifm_adapter *fm) { - int rc; + int rc = ida_alloc(&tifm_adapter_ids, GFP_KERNEL); - 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(); 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); - } + if (rc) + ida_free(&tifm_adapter_ids, fm->id); return rc; } @@ -226,9 +215,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); + ida_free(&tifm_adapter_ids, fm->id); device_del(&fm->dev); } EXPORT_SYMBOL(tifm_remove_adapter);