linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH-4.6 1/3] NVMe: Use simple ida interface
@ 2016-02-18 23:21 Keith Busch
  2016-02-18 23:21 ` [PATCH-4.6 2/3] NVMe: Code naming cleanup Keith Busch
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Keith Busch @ 2016-02-18 23:21 UTC (permalink / raw)


This is an easier interface to use and removes one of the overloaded
dev_list_lock uses.

Signed-off-by: Keith Busch <keith.busch at intel.com>
---
Feature was originally posted by Lee Duncan last October, but this missed
being applied.

 drivers/nvme/host/core.c | 20 ++++----------------
 1 file changed, 4 insertions(+), 16 deletions(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 9b1253f..04443b2 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1334,29 +1334,17 @@ static DEFINE_IDA(nvme_instance_ida);
 
 static int nvme_set_instance(struct nvme_ctrl *ctrl)
 {
-	int instance, error;
-
-	do {
-		if (!ida_pre_get(&nvme_instance_ida, GFP_KERNEL))
-			return -ENODEV;
-
-		spin_lock(&dev_list_lock);
-		error = ida_get_new(&nvme_instance_ida, &instance);
-		spin_unlock(&dev_list_lock);
-	} while (error == -EAGAIN);
-
-	if (error)
-		return -ENODEV;
+	int instance = ida_simple_get(&nvme_instance_ida, 0, 0, GFP_KERNEL);
 
+	if (instance < 0)
+		return instance;
 	ctrl->instance = instance;
 	return 0;
 }
 
 static void nvme_release_instance(struct nvme_ctrl *ctrl)
 {
-	spin_lock(&dev_list_lock);
-	ida_remove(&nvme_instance_ida, ctrl->instance);
-	spin_unlock(&dev_list_lock);
+	ida_simple_remove(&nvme_instance_ida, ctrl->instance);
 }
 
 void nvme_uninit_ctrl(struct nvme_ctrl *ctrl)
-- 
2.6.2.307.g37023ba

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-02-22  8:57 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-18 23:21 [PATCH-4.6 1/3] NVMe: Use simple ida interface Keith Busch
2016-02-18 23:21 ` [PATCH-4.6 2/3] NVMe: Code naming cleanup Keith Busch
2016-02-21 16:18   ` Christoph Hellwig
2016-02-22  8:57   ` Sagi Grimberg
2016-02-18 23:21 ` [PATCH-4.6 3/3] NVMe: Don't allow unsupported flags Keith Busch
2016-02-19 19:14   ` Derrick, Jonathan
2016-02-21 16:20   ` Christoph Hellwig
2016-02-21 16:18 ` [PATCH-4.6 1/3] NVMe: Use simple ida interface Christoph Hellwig
2016-02-22  8:56 ` Sagi Grimberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).