@@ -55,23 +55,14 @@ int dca_sysfs_add_provider(struct dca_provider *dca, struct device *dev)
struct device *cd;
int ret;
- idr_preload(GFP_KERNEL);
- spin_lock(&dca_idr_lock);
-
- ret = idr_alloc(&dca_idr, dca, 0, 0, GFP_NOWAIT);
- if (ret >= 0)
- dca->id = ret;
-
- spin_unlock(&dca_idr_lock);
- idr_preload_end();
+ ret = idr_get_index(&dca_idr, &dca_idr_lock, dca);
if (ret < 0)
return ret;
+ dca->id = ret;
cd = device_create(dca_class, dev, MKDEV(0, 0), NULL, "dca%d", dca->id);
if (IS_ERR(cd)) {
- spin_lock(&dca_idr_lock);
- idr_remove(&dca_idr, dca->id);
- spin_unlock(&dca_idr_lock);
+ idr_put_index(&dca_idr, &dca_idr_lock, dca->id);
return PTR_ERR(cd);
}
dca->cd = cd;
@@ -82,9 +73,7 @@ void dca_sysfs_remove_provider(struct dca_provider *dca)
{
device_unregister(dca->cd);
dca->cd = NULL;
- spin_lock(&dca_idr_lock);
- idr_remove(&dca_idr, dca->id);
- spin_unlock(&dca_idr_lock);
+ idr_put_index(&dca_idr, &dca_idr_lock, dca->id);
}
int __init dca_sysfs_init(void)
Signed-off-by: Lee Duncan <lduncan@suse.com> --- drivers/dca/dca-sysfs.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-)