From patchwork Thu Feb 21 00:21:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 10822913 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AED9914E1 for ; Thu, 21 Feb 2019 00:21:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9DF442FC4D for ; Thu, 21 Feb 2019 00:21:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 927BC2FC82; Thu, 21 Feb 2019 00:21:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3900A2FC4D for ; Thu, 21 Feb 2019 00:21:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726505AbfBUAVQ (ORCPT ); Wed, 20 Feb 2019 19:21:16 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:52508 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726919AbfBUAVO (ORCPT ); Wed, 20 Feb 2019 19:21:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=9o60OXyx6UzwXXsC3ijt9XTLR5UDYAq+HoJb1hR37Pc=; b=avaI0m+q+lWdG4JFj0LNrM4jG M3TyyFDPif+dDz0TVku0XWx5CjiejuAdGsIVJsjZeLuWLpfA98NLyDKD/4Glr6KtWbSYLqCDr23W3 6eGh0TbgC2eEVKGL6snycBcLcBDrNhzWmuyVUSpr2TpsFQl3T4mCDqcOOxveR6eAjx1YQzYhZ6ZaV QCcMe0sPYQUcqTaKB5Yyezc0UoTI/WcB5YxcbWY/n0LX/iq0ZXykDv5iX4kV5o0gJaSNGYdQA70MY 9YUUKmfwYyYC8gGliCgF5I+IaV7TI+rRLj8X0DiXZnukzuuXw1cAEQG2/Bmon6BKSMstDvvnS/1u9 p9w75yzxg==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1gwc6z-0005xJ-Mj; Thu, 21 Feb 2019 00:21:13 +0000 From: Matthew Wilcox To: Jason Gunthorpe Cc: Matthew Wilcox , linux-rdma@vger.kernel.org Subject: [PATCH 27/32] ocrdma: Convert ocrdma_dev_id to IDA Date: Wed, 20 Feb 2019 16:21:02 -0800 Message-Id: <20190221002107.22625-28-willy@infradead.org> X-Mailer: git-send-email 2.14.5 In-Reply-To: <20190221002107.22625-1-willy@infradead.org> References: <20190221002107.22625-1-willy@infradead.org> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This driver doesn't look up the pointer that it stores, so this can just be an IDA and save some memory. Signed-off-by: Matthew Wilcox --- drivers/infiniband/hw/ocrdma/ocrdma_main.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_main.c b/drivers/infiniband/hw/ocrdma/ocrdma_main.c index 1f393842453a..b014eeffbcce 100644 --- a/drivers/infiniband/hw/ocrdma/ocrdma_main.c +++ b/drivers/infiniband/hw/ocrdma/ocrdma_main.c @@ -62,7 +62,7 @@ MODULE_DESCRIPTION(OCRDMA_ROCE_DRV_DESC " " OCRDMA_ROCE_DRV_VERSION); MODULE_AUTHOR("Emulex Corporation"); MODULE_LICENSE("Dual BSD/GPL"); -static DEFINE_IDR(ocrdma_dev_id); +static DEFINE_IDA(ocrdma_dev_id); void ocrdma_get_guid(struct ocrdma_dev *dev, u8 *guid) { @@ -302,12 +302,12 @@ static struct ocrdma_dev *ocrdma_add(struct be_dev_info *dev_info) } dev->mbx_cmd = kzalloc(sizeof(struct ocrdma_mqe_emb_cmd), GFP_KERNEL); if (!dev->mbx_cmd) - goto idr_err; + goto ida_err; memcpy(&dev->nic_info, dev_info, sizeof(*dev_info)); - dev->id = idr_alloc(&ocrdma_dev_id, NULL, 0, 0, GFP_KERNEL); + dev->id = ida_alloc(&ocrdma_dev_id, GFP_KERNEL); if (dev->id < 0) - goto idr_err; + goto ida_err; status = ocrdma_init_hw(dev); if (status) @@ -345,8 +345,8 @@ static struct ocrdma_dev *ocrdma_add(struct be_dev_info *dev_info) ocrdma_free_resources(dev); ocrdma_cleanup_hw(dev); init_err: - idr_remove(&ocrdma_dev_id, dev->id); -idr_err: + ida_free(&ocrdma_dev_id, dev->id); +ida_err: kfree(dev->mbx_cmd); ib_dealloc_device(&dev->ibdev); pr_err("%s() leaving. ret=%d\n", __func__, status); @@ -355,8 +355,7 @@ static struct ocrdma_dev *ocrdma_add(struct be_dev_info *dev_info) static void ocrdma_remove_free(struct ocrdma_dev *dev) { - - idr_remove(&ocrdma_dev_id, dev->id); + ida_free(&ocrdma_dev_id, dev->id); kfree(dev->mbx_cmd); ib_dealloc_device(&dev->ibdev); } @@ -461,7 +460,6 @@ static void __exit ocrdma_exit_module(void) { be_roce_unregister_driver(&ocrdma_drv); ocrdma_rem_debugfs(); - idr_destroy(&ocrdma_dev_id); } module_init(ocrdma_init_module);