]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
memstick: convert to idr_alloc()
authorTejun Heo <tj@kernel.org>
Thu, 28 Feb 2013 01:04:28 +0000 (17:04 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 28 Feb 2013 03:10:17 +0000 (19:10 -0800)
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>
drivers/memstick/core/memstick.c
drivers/memstick/core/mspro_block.c

index 56ff19cdc2ad81ca015b9e9364318609921dcace..ffcb10ac434156adc89e4e9237d30e4ade530830 100644 (file)
@@ -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);
 
index 9729b92fbfdd3150280328a2be3d5872beacd618..f12b78dbce0426ba28fb156f1cf48c412fa75196 100644 (file)
@@ -1213,21 +1213,10 @@ static int mspro_block_init_disk(struct memstick_dev *card)
        msb->page_size = be16_to_cpu(sys_info->unit_size);
 
        mutex_lock(&mspro_block_disk_lock);
-       if (!idr_pre_get(&mspro_block_disk_idr, GFP_KERNEL)) {
-               mutex_unlock(&mspro_block_disk_lock);
-               return -ENOMEM;
-       }
-
-       rc = idr_get_new(&mspro_block_disk_idr, card, &disk_id);
+       disk_id = idr_alloc(&mspro_block_disk_idr, card, 0, 256, GFP_KERNEL);
        mutex_unlock(&mspro_block_disk_lock);
-
-       if (rc)
-               return rc;
-
-       if ((disk_id << MSPRO_BLOCK_PART_SHIFT) > 255) {
-               rc = -ENOSPC;
-               goto out_release_id;
-       }
+       if (disk_id < 0)
+               return disk_id;
 
        msb->disk = alloc_disk(1 << MSPRO_BLOCK_PART_SHIFT);
        if (!msb->disk) {