diff options
author | Tejun Heo <tj@kernel.org> | 2013-02-27 20:04:28 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-27 22:10:17 -0500 |
commit | 7b51f47835f61d9ee6273908b774a0f569e99646 (patch) | |
tree | 88eb8561b44342f5531b459eabd17f0a2d99647d | |
parent | c9d76be696bbb76ba1081d2b0fc0086f449788da (diff) |
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>
-rw-r--r-- | drivers/memstick/core/memstick.c | 21 | ||||
-rw-r--r-- | drivers/memstick/core/mspro_block.c | 17 |
2 files changed, 13 insertions, 25 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) | |||
512 | { | 512 | { |
513 | int rc; | 513 | int rc; |
514 | 514 | ||
515 | while (1) { | 515 | idr_preload(GFP_KERNEL); |
516 | if (!idr_pre_get(&memstick_host_idr, GFP_KERNEL)) | 516 | spin_lock(&memstick_host_lock); |
517 | return -ENOMEM; | ||
518 | 517 | ||
519 | spin_lock(&memstick_host_lock); | 518 | rc = idr_alloc(&memstick_host_idr, host, 0, 0, GFP_NOWAIT); |
520 | rc = idr_get_new(&memstick_host_idr, host, &host->id); | 519 | if (rc >= 0) |
521 | spin_unlock(&memstick_host_lock); | 520 | host->id = rc; |
522 | if (!rc) | 521 | |
523 | break; | 522 | spin_unlock(&memstick_host_lock); |
524 | else if (rc != -EAGAIN) | 523 | idr_preload_end(); |
525 | return rc; | 524 | if (rc < 0) |
526 | } | 525 | return rc; |
527 | 526 | ||
528 | dev_set_name(&host->dev, "memstick%u", host->id); | 527 | dev_set_name(&host->dev, "memstick%u", host->id); |
529 | 528 | ||
diff --git a/drivers/memstick/core/mspro_block.c b/drivers/memstick/core/mspro_block.c index 9729b92fbfdd..f12b78dbce04 100644 --- a/drivers/memstick/core/mspro_block.c +++ b/drivers/memstick/core/mspro_block.c | |||
@@ -1213,21 +1213,10 @@ static int mspro_block_init_disk(struct memstick_dev *card) | |||
1213 | msb->page_size = be16_to_cpu(sys_info->unit_size); | 1213 | msb->page_size = be16_to_cpu(sys_info->unit_size); |
1214 | 1214 | ||
1215 | mutex_lock(&mspro_block_disk_lock); | 1215 | mutex_lock(&mspro_block_disk_lock); |
1216 | if (!idr_pre_get(&mspro_block_disk_idr, GFP_KERNEL)) { | 1216 | disk_id = idr_alloc(&mspro_block_disk_idr, card, 0, 256, GFP_KERNEL); |
1217 | mutex_unlock(&mspro_block_disk_lock); | ||
1218 | return -ENOMEM; | ||
1219 | } | ||
1220 | |||
1221 | rc = idr_get_new(&mspro_block_disk_idr, card, &disk_id); | ||
1222 | mutex_unlock(&mspro_block_disk_lock); | 1217 | mutex_unlock(&mspro_block_disk_lock); |
1223 | 1218 | if (disk_id < 0) | |
1224 | if (rc) | 1219 | return disk_id; |
1225 | return rc; | ||
1226 | |||
1227 | if ((disk_id << MSPRO_BLOCK_PART_SHIFT) > 255) { | ||
1228 | rc = -ENOSPC; | ||
1229 | goto out_release_id; | ||
1230 | } | ||
1231 | 1220 | ||
1232 | msb->disk = alloc_disk(1 << MSPRO_BLOCK_PART_SHIFT); | 1221 | msb->disk = alloc_disk(1 << MSPRO_BLOCK_PART_SHIFT); |
1233 | if (!msb->disk) { | 1222 | if (!msb->disk) { |