Skip to content

Commit

Permalink
mmc: 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 <tj@kernel.org>
Cc: Chris Ball <cjb@laptop.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Tejun Heo authored and Linus Torvalds committed Feb 28, 2013
1 parent 57f2667 commit 803d9e0
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions drivers/mmc/core/host.c
Original file line number Diff line number Diff line change
Expand Up @@ -429,19 +429,20 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev)
int err;
struct mmc_host *host;

if (!idr_pre_get(&mmc_host_idr, GFP_KERNEL))
return NULL;

host = kzalloc(sizeof(struct mmc_host) + extra, GFP_KERNEL);
if (!host)
return NULL;

/* scanning will be enabled when we're ready */
host->rescan_disable = 1;
idr_preload(GFP_KERNEL);
spin_lock(&mmc_host_lock);
err = idr_get_new(&mmc_host_idr, host, &host->index);
err = idr_alloc(&mmc_host_idr, host, 0, 0, GFP_NOWAIT);
if (err >= 0)
host->index = err;
spin_unlock(&mmc_host_lock);
if (err)
idr_preload_end();
if (err < 0)
goto free;

dev_set_name(&host->class_dev, "mmc%d", host->index);
Expand Down

0 comments on commit 803d9e0

Please sign in to comment.