linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: keith.busch@intel.com (Keith Busch)
Subject: [PATCH-4.6 1/3] NVMe: Use simple ida interface
Date: Thu, 18 Feb 2016 16:21:15 -0700	[thread overview]
Message-ID: <1455837677-23248-1-git-send-email-keith.busch@intel.com> (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

             reply	other threads:[~2016-02-18 23:21 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-18 23:21 Keith Busch [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1455837677-23248-1-git-send-email-keith.busch@intel.com \
    --to=keith.busch@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).