diff options
author | Tejun Heo <tj@kernel.org> | 2013-02-27 17:04:28 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-27 19:10:17 -0800 |
commit | 7b51f47835f61d9ee6273908b774a0f569e99646 (patch) | |
tree | 88eb8561b44342f5531b459eabd17f0a2d99647d /drivers/memstick/core/memstick.c | |
parent | c9d76be696bbb76ba1081d2b0fc0086f449788da (diff) | |
download | lwn-7b51f47835f61d9ee6273908b774a0f569e99646.tar.gz lwn-7b51f47835f61d9ee6273908b774a0f569e99646.zip |
memstick: convert to idr_alloc()
Convert to the much saner new idr interface.
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Alex Dubov <oakad@yahoo.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/memstick/core/memstick.c')
-rw-r--r-- | drivers/memstick/core/memstick.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/drivers/memstick/core/memstick.c b/drivers/memstick/core/memstick.c index 56ff19cdc2ad..ffcb10ac4341 100644 --- a/drivers/memstick/core/memstick.c +++ b/drivers/memstick/core/memstick.c @@ -512,18 +512,17 @@ int memstick_add_host(struct memstick_host *host) { int rc; - while (1) { - if (!idr_pre_get(&memstick_host_idr, GFP_KERNEL)) - return -ENOMEM; + idr_preload(GFP_KERNEL); + spin_lock(&memstick_host_lock); - spin_lock(&memstick_host_lock); - rc = idr_get_new(&memstick_host_idr, host, &host->id); - spin_unlock(&memstick_host_lock); - if (!rc) - break; - else if (rc != -EAGAIN) - return rc; - } + rc = idr_alloc(&memstick_host_idr, host, 0, 0, GFP_NOWAIT); + if (rc >= 0) + host->id = rc; + + spin_unlock(&memstick_host_lock); + idr_preload_end(); + if (rc < 0) + return rc; dev_set_name(&host->dev, "memstick%u", host->id); |