Commit 615f2e5c authored by Tejun Heo's avatar Tejun Heo Committed by Linus Torvalds

dca: convert to idr_alloc()

Convert to the much saner new idr interface.
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
Cc: Maciej Sosnowski <maciej.sosnowski@intel.com>
Cc: Shannon Nelson <shannon.nelson@intel.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 56de2102
...@@ -53,22 +53,19 @@ void dca_sysfs_remove_req(struct dca_provider *dca, int slot) ...@@ -53,22 +53,19 @@ void dca_sysfs_remove_req(struct dca_provider *dca, int slot)
int dca_sysfs_add_provider(struct dca_provider *dca, struct device *dev) int dca_sysfs_add_provider(struct dca_provider *dca, struct device *dev)
{ {
struct device *cd; struct device *cd;
int err = 0; int ret;
idr_try_again: idr_preload(GFP_KERNEL);
if (!idr_pre_get(&dca_idr, GFP_KERNEL))
return -ENOMEM;
spin_lock(&dca_idr_lock); spin_lock(&dca_idr_lock);
err = idr_get_new(&dca_idr, dca, &dca->id);
ret = idr_alloc(&dca_idr, dca, 0, 0, GFP_NOWAIT);
if (ret >= 0)
dca->id = ret;
spin_unlock(&dca_idr_lock); spin_unlock(&dca_idr_lock);
switch (err) { idr_preload_end();
case 0: if (ret < 0)
break; return ret;
case -EAGAIN:
goto idr_try_again;
default:
return err;
}
cd = device_create(dca_class, dev, MKDEV(0, 0), NULL, "dca%d", dca->id); cd = device_create(dca_class, dev, MKDEV(0, 0), NULL, "dca%d", dca->id);
if (IS_ERR(cd)) { if (IS_ERR(cd)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment