From patchwork Wed Feb 6 19:40:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejun Heo X-Patchwork-Id: 2107221 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 71EAD3FCFC for ; Wed, 6 Feb 2013 20:00:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757989Ab3BFUAI (ORCPT ); Wed, 6 Feb 2013 15:00:08 -0500 Received: from mail-ie0-f181.google.com ([209.85.223.181]:60758 "EHLO mail-ie0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758029Ab3BFTuj (ORCPT ); Wed, 6 Feb 2013 14:50:39 -0500 Received: by mail-ie0-f181.google.com with SMTP id 17so2371151iea.40 for ; Wed, 06 Feb 2013 11:50:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=5y4f7AS8aRF1GZGTyt95D9FTo29S7EXoKW6lGyFsGa4=; b=Bany682hmROF3nZ7LaQX77vyDkylCBY+Po40YtSs2587pFEBwlNquBjCOKSuMFHZiC ZgUIy9oNcu3taahNWCRdhBJ+CB1x5GUUoKtrqLQSPshAoTEO3pOxaN6N2lw3tFA9WSvo Mui2EVGUclgKDjBp6o9VU5la3SfocXZHc2D+g0m6XncJrSovBeR/bwKoHSCzH68bYYtP eIURjNXMkr9V1HDj1NvEY3ZNyb8zszsD5HzrVg+4zNmVDh9WhgprXpCHtB687/qChwkT ON9ZjGvYEGSl/v+vFIppvTXIiNDmGtN8GK5qwpLUbg9QkTy/tZ8lrv8/5D8X8T1kM9+u WiNw== X-Received: by 10.50.191.228 with SMTP id hb4mr8634576igc.37.1360180239151; Wed, 06 Feb 2013 11:50:39 -0800 (PST) Received: from htj.dyndns.org (c-69-181-251-227.hsd1.ca.comcast.net. [69.181.251.227]) by mx.google.com with ESMTPS id l5sm39989590pax.10.2013.02.06.11.50.37 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 06 Feb 2013 11:50:38 -0800 (PST) From: Tejun Heo To: akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, Tejun Heo , Mike Marciniszyn , linux-rdma@vger.kernel.org Subject: [PATCH 46/77] IB/qib: convert to idr_alloc() Date: Wed, 6 Feb 2013 11:40:18 -0800 Message-Id: <1360179649-22465-47-git-send-email-tj@kernel.org> X-Mailer: git-send-email 1.8.1 In-Reply-To: <1360179649-22465-1-git-send-email-tj@kernel.org> References: <1360179649-22465-1-git-send-email-tj@kernel.org> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Convert to the much saner new idr interface. Only compile tested. Signed-off-by: Tejun Heo Cc: Mike Marciniszyn Cc: linux-rdma@vger.kernel.org --- 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();