Skip to content

Commit

Permalink
dca: convert to idr_alloc()
Browse files Browse the repository at this point in the history
Convert to the much saner new idr interface.

Signed-off-by: Tejun Heo <[email protected]>
Cc: Paul Gortmaker <[email protected]>
Cc: Maciej Sosnowski <[email protected]>
Cc: Shannon Nelson <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
htejun authored and torvalds committed Feb 28, 2013
1 parent 56de210 commit 615f2e5
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions drivers/dca/dca-sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
struct device *cd;
int err = 0;
int ret;

idr_try_again:
if (!idr_pre_get(&dca_idr, GFP_KERNEL))
return -ENOMEM;
idr_preload(GFP_KERNEL);
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);
switch (err) {
case 0:
break;
case -EAGAIN:
goto idr_try_again;
default:
return err;
}
idr_preload_end();
if (ret < 0)
return ret;

cd = device_create(dca_class, dev, MKDEV(0, 0), NULL, "dca%d", dca->id);
if (IS_ERR(cd)) {
Expand Down

0 comments on commit 615f2e5

Please sign in to comment.