scsi/lpfc: convert to idr_alloc()
authorTejun Heo <tj@kernel.org>
Thu, 28 Feb 2013 01:04:44 +0000 (17:04 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 28 Feb 2013 03:10:19 +0000 (19:10 -0800)
Convert to the much saner new idr interface.

Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: James Smart <james.smart@emulex.com>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/scsi/lpfc/lpfc_init.c

index 89ad558..7de4ef1 100644 (file)
@@ -3165,14 +3165,10 @@ destroy_port(struct lpfc_vport *vport)
 int
 lpfc_get_instance(void)
 {
-       int instance = 0;
-
-       /* Assign an unused number */
-       if (!idr_pre_get(&lpfc_hba_index, GFP_KERNEL))
-               return -1;
-       if (idr_get_new(&lpfc_hba_index, NULL, &instance))
-               return -1;
-       return instance;
+       int ret;
+
+       ret = idr_alloc(&lpfc_hba_index, NULL, 0, 0, GFP_KERNEL);
+       return ret < 0 ? -1 : ret;
 }
 
 /**