From patchwork Wed Apr 10 09:10:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Devesh Sharma X-Patchwork-Id: 10893493 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 4098E922 for ; Wed, 10 Apr 2019 09:10:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C03F289FB for ; Wed, 10 Apr 2019 09:10:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1FDAA289FF; Wed, 10 Apr 2019 09:10:23 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 A077F28A02 for ; Wed, 10 Apr 2019 09:10:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729819AbfDJJKV (ORCPT ); Wed, 10 Apr 2019 05:10:21 -0400 Received: from mail-yw1-f66.google.com ([209.85.161.66]:41351 "EHLO mail-yw1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729143AbfDJJKV (ORCPT ); Wed, 10 Apr 2019 05:10:21 -0400 Received: by mail-yw1-f66.google.com with SMTP id l15so471802ywe.8 for ; Wed, 10 Apr 2019 02:10:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id; bh=X3FXnG2iatM/GhUZTtClej1QVqraqeLvvBvzMdYVTOs=; b=JMFdvsnTJeGKmlaDrOg5tTLPbMU2S+bwnM1V+RTUDXywxhuwKjtW+nLnL9xEnSOJfz 0pcR2OtkN1RRif2RKpZ7aXwv/SrIEllSpbI6P1Lbhezfl46INRABJrs1cbS1eKN/Iemg ByYwu8FcG/jdG+sfMOfeu6IWMisTJtlEcPTi0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=X3FXnG2iatM/GhUZTtClej1QVqraqeLvvBvzMdYVTOs=; b=Ydj52sKejHlCwE83pLwnG7PksFb0bJm4bW+taxFcGomGdeuBwCEXdpZJrN1eGC8GcE 49YIIVUTHUd8AxcziEkmlV7IT2xdin+CGU9jXhFhw+bJFj+ndmzSeCkLskhwe36p0vDN vqFU5ad2/fofcOW7itdltYdxxR/STLSaDTvCE8BX54usID3uxYL9DFREx5IHTJY3JVSl y81v2nyC0mORnJDtK3Ut2ELAStPmKFEnBu8fZPvvVG6Pb7PqvEoBcLmcnD6mFq4kus2f X5ydi/ymoVgsqn44h4oTqZqfmipFHV83k0INox0Y9/IwWWtakdCd1SfANRt5bdMjYky7 p47A== X-Gm-Message-State: APjAAAW0/B1RFp8a1MXblSRmBpobR5QjHwQCinaUnHlGYTn+ytqLvbJ7 YLhOeRjdydwWdP/qbF5m96qKZ1h/wLcpmDHkoNJXJeVPXD58zgpFo+pJl4FhStBzSheaVs6kDBk BDoobVaEKHmdjowzcdUTJ3mxzbTPl+zLZHaivep3ZhdEYWZKianQiUlKcOF4zz8Dj9AAD+asrc2 ZGtcs= X-Google-Smtp-Source: APXvYqzRpVZnwre2TX+ym0CiO0ySSZKCK8uAJnSzkw7oh1IXXQWSkgQxYapdA648BSeHngd9F3zZSg== X-Received: by 2002:a81:4d8b:: with SMTP id a133mr32873845ywb.122.1554887420130; Wed, 10 Apr 2019 02:10:20 -0700 (PDT) Received: from neo00-el73.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id k125sm21778605ywb.26.2019.04.10.02.10.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Apr 2019 02:10:19 -0700 (PDT) From: Devesh Sharma To: linux-rdma@vger.kernel.org Cc: jgg@mellanox.com, Devesh Sharma Subject: [PATCH] RDMA/ocrdma: remove use of idr use pci bdf instead Date: Wed, 10 Apr 2019 05:10:07 -0400 Message-Id: <1554887407-17965-1-git-send-email-devesh.sharma@broadcom.com> X-Mailer: git-send-email 1.8.3.1 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 removing the use of IDR variable just to name the function ids. Using the PCI_FUNC(pdev->devfn) instead to create the device name, associated resources and to print driver into at various places. Reported-by: Matthew Wilcox Signed-off-by: Devesh Sharma --- drivers/infiniband/hw/ocrdma/ocrdma_main.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_main.c b/drivers/infiniband/hw/ocrdma/ocrdma_main.c index 34d3d59..8bc2f97 100644 --- a/drivers/infiniband/hw/ocrdma/ocrdma_main.c +++ b/drivers/infiniband/hw/ocrdma/ocrdma_main.c @@ -62,8 +62,6 @@ MODULE_AUTHOR("Emulex Corporation"); MODULE_LICENSE("Dual BSD/GPL"); -static DEFINE_IDR(ocrdma_dev_id); - void ocrdma_get_guid(struct ocrdma_dev *dev, u8 *guid) { u8 mac_addr[6]; @@ -310,13 +308,10 @@ 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 init_err; memcpy(&dev->nic_info, dev_info, sizeof(*dev_info)); - dev->id = idr_alloc(&ocrdma_dev_id, NULL, 0, 0, GFP_KERNEL); - if (dev->id < 0) - goto idr_err; - + dev->id = PCI_FUNC(dev->nic_info.pdev->devfn); status = ocrdma_init_hw(dev); if (status) goto init_err; @@ -353,8 +348,6 @@ 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: kfree(dev->mbx_cmd); ib_dealloc_device(&dev->ibdev); pr_err("%s() leaving. ret=%d\n", __func__, status); @@ -364,7 +357,6 @@ 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); kfree(dev->mbx_cmd); ib_dealloc_device(&dev->ibdev); } @@ -469,7 +461,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);