linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: akpm@linux-foundation.org
Cc: linux-kernel@vger.kernel.org, rusty@rustcorp.com.au,
	bfields@fieldses.org, skinsbursky@parallels.com,
	ebiederm@xmission.com, jmorris@namei.org, axboe@kernel.dk,
	Tejun Heo <tj@kernel.org>,
	Mike Marciniszyn <infinipath@intel.com>,
	linux-rdma@vger.kernel.org
Subject: [PATCH 30/62] infiniband/qib: convert to idr_alloc()
Date: Sat,  2 Feb 2013 17:20:31 -0800	[thread overview]
Message-ID: <1359854463-2538-31-git-send-email-tj@kernel.org> (raw)
In-Reply-To: <1359854463-2538-1-git-send-email-tj@kernel.org>

Convert to the much saner new idr interface.

Only compile tested.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Mike Marciniszyn <infinipath@intel.com>
Cc: linux-rdma@vger.kernel.org
---
This patch depends on an earlier idr changes and I think it would be
best to route these together through -mm.  Please holler if there's
any objection.  Thanks.

 drivers/infiniband/hw/qib/qib_init.c | 21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/drivers/infiniband/hw/qib/qib_init.c b/drivers/infiniband/hw/qib/qib_init.c
index ddf066d..50e33aa 100644
--- a/drivers/infiniband/hw/qib/qib_init.c
+++ b/drivers/infiniband/hw/qib/qib_init.c
@@ -1060,22 +1060,23 @@ struct qib_devdata *qib_alloc_devdata(struct pci_dev *pdev, size_t extra)
 	struct qib_devdata *dd;
 	int ret;
 
-	if (!idr_pre_get(&qib_unit_table, GFP_KERNEL)) {
-		dd = ERR_PTR(-ENOMEM);
-		goto bail;
-	}
-
 	dd = (struct qib_devdata *) ib_alloc_device(sizeof(*dd) + extra);
 	if (!dd) {
 		dd = ERR_PTR(-ENOMEM);
 		goto bail;
 	}
 
+	idr_preload(GFP_KERNEL);
 	spin_lock_irqsave(&qib_devs_lock, flags);
-	ret = idr_get_new(&qib_unit_table, dd, &dd->unit);
-	if (ret >= 0)
+
+	ret = idr_alloc(&qib_unit_table, dd, 0, 0, GFP_NOWAIT);
+	if (ret >= 0) {
+		dd->unit = ret;
 		list_add(&dd->list, &qib_dev_list);
+	}
+
 	spin_unlock_irqrestore(&qib_devs_lock, flags);
+	idr_preload_end();
 
 	if (ret < 0) {
 		qib_early_err(&pdev->dev,
@@ -1180,11 +1181,6 @@ static int __init qlogic_ib_init(void)
 	 * the PCI subsystem.
 	 */
 	idr_init(&qib_unit_table);
-	if (!idr_pre_get(&qib_unit_table, GFP_KERNEL)) {
-		pr_err("idr_pre_get() failed\n");
-		ret = -ENOMEM;
-		goto bail_cq_wq;
-	}
 
 	ret = pci_register_driver(&qib_driver);
 	if (ret < 0) {
@@ -1199,7 +1195,6 @@ static int __init qlogic_ib_init(void)
 
 bail_unit:
 	idr_destroy(&qib_unit_table);
-bail_cq_wq:
 	destroy_workqueue(qib_cq_wq);
 bail_dev:
 	qib_dev_cleanup();
-- 
1.8.1

      parent reply	other threads:[~2013-02-03  1:20 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1359854463-2538-1-git-send-email-tj@kernel.org>
2013-02-03  1:20 ` [PATCH 22/62] infiniband/core: convert to idr_alloc() Tejun Heo
     [not found]   ` <1359854463-2538-23-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-02-04 16:43     ` [PATCH v2 " Tejun Heo
     [not found]       ` <20130204164355.GD27963-9pTldWuhBndy/B6EtB590w@public.gmane.org>
2013-02-05  0:07         ` Hefty, Sean
2013-02-03  1:20 ` [PATCH 23/62] infiniband/amso1100: " Tejun Heo
     [not found]   ` <1359854463-2538-24-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-02-03 14:36     ` Steve Wise
2013-02-03  1:20 ` [PATCH 24/62] infiniband/cxgb3: " Tejun Heo
     [not found]   ` <1359854463-2538-25-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-02-03 14:37     ` Steve Wise
     [not found] ` <1359854463-2538-1-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-02-03  1:20   ` [PATCH 25/62] infiniband/cxgb4: " Tejun Heo
     [not found]     ` <1359854463-2538-26-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-02-03 14:18       ` Steve Wise
2013-02-03 14:28         ` Tejun Heo
2013-02-04 15:32       ` Steve Wise
2013-02-03  1:20   ` [PATCH 26/62] infiniband/ehca: " Tejun Heo
2013-02-03  1:20 ` [PATCH 27/62] infiniband/ipath: " Tejun Heo
     [not found]   ` <1359854463-2538-28-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-02-04 16:15     ` Marciniszyn, Mike
     [not found]       ` <32E1700B9017364D9B60AED9960492BC0D58DDB2-AtyAts71sc88Ug9VwtkbtrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2013-02-04 16:18         ` Tejun Heo
2013-02-03  1:20 ` [PATCH 28/62] infiniband/mlx4: " Tejun Heo
2013-02-03  1:20 ` [PATCH 29/62] infiniband/ocrdma: " Tejun Heo
2013-02-03  1:20 ` Tejun Heo [this message]

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=1359854463-2538-31-git-send-email-tj@kernel.org \
    --to=tj@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=axboe@kernel.dk \
    --cc=bfields@fieldses.org \
    --cc=ebiederm@xmission.com \
    --cc=infinipath@intel.com \
    --cc=jmorris@namei.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=rusty@rustcorp.com.au \
    --cc=skinsbursky@parallels.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).