From patchwork Wed Jun 9 22:11:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Russ Weight X-Patchwork-Id: 12311335 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B5D4C48BCF for ; Wed, 9 Jun 2021 22:14:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4EEB7613EA for ; Wed, 9 Jun 2021 22:14:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229655AbhFIWQd (ORCPT ); Wed, 9 Jun 2021 18:16:33 -0400 Received: from mga18.intel.com ([134.134.136.126]:22619 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229535AbhFIWQd (ORCPT ); Wed, 9 Jun 2021 18:16:33 -0400 IronPort-SDR: pN8id4La16xHtIkrXgzEnCLFP6ArhGIb0fIZAV2ll+zhlaubj8lZPpK6rtq1yLz2Ys2hvnNVMC zkI0z9IKlGLg== X-IronPort-AV: E=McAfee;i="6200,9189,10010"; a="192496203" X-IronPort-AV: E=Sophos;i="5.83,261,1616482800"; d="scan'208";a="192496203" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2021 15:14:37 -0700 IronPort-SDR: 0M42UQVX/CR/4ZlSqe1X5+Al3kq3ATJQeWEWDbMFqEN4wmcWoCaZGeNnB1xeh0dWk0fPsMcxMl McJ8Jta93Y5A== X-IronPort-AV: E=Sophos;i="5.83,261,1616482800"; d="scan'208";a="477095298" Received: from rhweight-mobl2.amr.corp.intel.com (HELO rhweight-mobl2.ra.intel.com) ([10.251.20.114]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2021 15:14:36 -0700 From: Russ Weight To: mdf@kernel.org, linux-fpga@vger.kernel.org Cc: trix@redhat.com, lgoncalv@redhat.com, yilun.xu@intel.com, hao.wu@intel.com, matthew.gerlach@intel.com, richard.gong@intel.com, Russ Weight Subject: [PATCH v2 1/8] fpga: altera-pr-ip: Remove function alt_pr_unregister Date: Wed, 9 Jun 2021 15:11:28 -0700 Message-Id: <20210609221135.261837-2-russell.h.weight@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210609221135.261837-1-russell.h.weight@intel.com> References: <20210609221135.261837-1-russell.h.weight@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org Remove the alt_pr_unregister() function; it is no longer used. Signed-off-by: Russ Weight Reviewed-by: Xu Yilun --- v2: - The first version of this patch was entitled: "fpga: altera-pr-ip: Remove function alt_pr_unregister". This version of the patch removes the alt_pr_unregister() function altogether, instead of just removing portions of it. --- drivers/fpga/altera-pr-ip-core.c | 10 ---------- include/linux/fpga/altera-pr-ip-core.h | 1 - 2 files changed, 11 deletions(-) diff --git a/drivers/fpga/altera-pr-ip-core.c b/drivers/fpga/altera-pr-ip-core.c index 5b130c4d9882..dfdf21ed34c4 100644 --- a/drivers/fpga/altera-pr-ip-core.c +++ b/drivers/fpga/altera-pr-ip-core.c @@ -199,16 +199,6 @@ int alt_pr_register(struct device *dev, void __iomem *reg_base) } EXPORT_SYMBOL_GPL(alt_pr_register); -void alt_pr_unregister(struct device *dev) -{ - struct fpga_manager *mgr = dev_get_drvdata(dev); - - dev_dbg(dev, "%s\n", __func__); - - fpga_mgr_unregister(mgr); -} -EXPORT_SYMBOL_GPL(alt_pr_unregister); - MODULE_AUTHOR("Matthew Gerlach "); MODULE_DESCRIPTION("Altera Partial Reconfiguration IP Core"); MODULE_LICENSE("GPL v2"); diff --git a/include/linux/fpga/altera-pr-ip-core.h b/include/linux/fpga/altera-pr-ip-core.h index 0b08ac20ab16..a6b4c07858cc 100644 --- a/include/linux/fpga/altera-pr-ip-core.h +++ b/include/linux/fpga/altera-pr-ip-core.h @@ -13,6 +13,5 @@ #include int alt_pr_register(struct device *dev, void __iomem *reg_base); -void alt_pr_unregister(struct device *dev); #endif /* _ALT_PR_IP_CORE_H */ From patchwork Wed Jun 9 22:11:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Russ Weight X-Patchwork-Id: 12311337 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E58B3C48BCF for ; Wed, 9 Jun 2021 22:14:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C9F0F61377 for ; Wed, 9 Jun 2021 22:14:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229678AbhFIWQo (ORCPT ); Wed, 9 Jun 2021 18:16:44 -0400 Received: from mga18.intel.com ([134.134.136.126]:22626 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229535AbhFIWQn (ORCPT ); Wed, 9 Jun 2021 18:16:43 -0400 IronPort-SDR: x3Qb8omvxnaP9g6BxxFcDK5vaNZeUymXR0cZnt5MzKvZcwbsCmzqi2pfjPg+XTOHfiYLT+6b9Z S1KN+4cvgNsQ== X-IronPort-AV: E=McAfee;i="6200,9189,10010"; a="192496207" X-IronPort-AV: E=Sophos;i="5.83,261,1616482800"; d="scan'208";a="192496207" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2021 15:14:39 -0700 IronPort-SDR: dII4NCOHqnfqDwCxZfpW50sTIc+QYkf03LaczQgX9RXfw1+1L4V2T6ow9AAtMX1BVrNCdJVPV8 k99q1jjJebcw== X-IronPort-AV: E=Sophos;i="5.83,261,1616482800"; d="scan'208";a="477095311" Received: from rhweight-mobl2.amr.corp.intel.com (HELO rhweight-mobl2.ra.intel.com) ([10.251.20.114]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2021 15:14:38 -0700 From: Russ Weight To: mdf@kernel.org, linux-fpga@vger.kernel.org Cc: trix@redhat.com, lgoncalv@redhat.com, yilun.xu@intel.com, hao.wu@intel.com, matthew.gerlach@intel.com, richard.gong@intel.com, Russ Weight Subject: [PATCH v2 2/8] fpga: stratix10-soc: Add missing fpga_mgr_free() call Date: Wed, 9 Jun 2021 15:11:29 -0700 Message-Id: <20210609221135.261837-3-russell.h.weight@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210609221135.261837-1-russell.h.weight@intel.com> References: <20210609221135.261837-1-russell.h.weight@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org The stratix10-soc driver uses fpga_mgr_create() function and is therefore responsible to call fpga_mgr_free() to release the class driver resources. Add a missing call to fpga_mgr_free in the s10_remove() function. Signed-off-by: Russ Weight Reviewed-by: Xu Yilun --- v2: - Added reviewed-by tag --- drivers/fpga/stratix10-soc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/fpga/stratix10-soc.c b/drivers/fpga/stratix10-soc.c index 657a70c5fc99..9e34bbbce26e 100644 --- a/drivers/fpga/stratix10-soc.c +++ b/drivers/fpga/stratix10-soc.c @@ -454,6 +454,7 @@ static int s10_remove(struct platform_device *pdev) struct s10_priv *priv = mgr->priv; fpga_mgr_unregister(mgr); + fpga_mgr_free(mgr); stratix10_svc_free_channel(priv->chan); return 0; From patchwork Wed Jun 9 22:11:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Russ Weight X-Patchwork-Id: 12311339 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 86E55C48BD1 for ; Wed, 9 Jun 2021 22:14:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 708E2613EA for ; Wed, 9 Jun 2021 22:14:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229788AbhFIWQo (ORCPT ); Wed, 9 Jun 2021 18:16:44 -0400 Received: from mga18.intel.com ([134.134.136.126]:22626 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229705AbhFIWQo (ORCPT ); Wed, 9 Jun 2021 18:16:44 -0400 IronPort-SDR: cIllBtz6WkI9m3fkLRmEzdVCgW/eXp1ycYg+oipYHCRbu4i1kbkVVQMW40gtNi18NzlE34+h3P Ga13lpYN/TMw== X-IronPort-AV: E=McAfee;i="6200,9189,10010"; a="192496212" X-IronPort-AV: E=Sophos;i="5.83,261,1616482800"; d="scan'208";a="192496212" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2021 15:14:40 -0700 IronPort-SDR: KldrJ27NTabh3/CdR9Ahr09h1b0NXe4mEPYxaXW07z5mJPvWpWC4baj1jPvaI7aX7KUfByCF+O k0frwOGrk44A== X-IronPort-AV: E=Sophos;i="5.83,261,1616482800"; d="scan'208";a="477095320" Received: from rhweight-mobl2.amr.corp.intel.com (HELO rhweight-mobl2.ra.intel.com) ([10.251.20.114]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2021 15:14:39 -0700 From: Russ Weight To: mdf@kernel.org, linux-fpga@vger.kernel.org Cc: trix@redhat.com, lgoncalv@redhat.com, yilun.xu@intel.com, hao.wu@intel.com, matthew.gerlach@intel.com, richard.gong@intel.com, Russ Weight Subject: [PATCH v2 3/8] fpga: mgr: Rename dev to parent for parent device Date: Wed, 9 Jun 2021 15:11:30 -0700 Message-Id: <20210609221135.261837-4-russell.h.weight@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210609221135.261837-1-russell.h.weight@intel.com> References: <20210609221135.261837-1-russell.h.weight@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org Rename variable "dev" to "parent" in cases where it represents the parent device. Signed-off-by: Russ Weight Reviewed-by: Xu Yilun --- v2: - This patch contains the renaming of "dev" to "parent" that was previously part of the patch: "fpga: mgr: Use standard dev_release for class driver" --- drivers/fpga/fpga-mgr.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c index b85bc47c91a9..42ddc0844781 100644 --- a/drivers/fpga/fpga-mgr.c +++ b/drivers/fpga/fpga-mgr.c @@ -551,7 +551,7 @@ EXPORT_SYMBOL_GPL(fpga_mgr_unlock); /** * fpga_mgr_create - create and initialize a FPGA manager struct - * @dev: fpga manager device from pdev + * @parent: fpga manager device from pdev * @name: fpga manager name * @mops: pointer to structure of fpga manager ops * @priv: fpga manager private data @@ -561,7 +561,7 @@ EXPORT_SYMBOL_GPL(fpga_mgr_unlock); * * Return: pointer to struct fpga_manager or NULL */ -struct fpga_manager *fpga_mgr_create(struct device *dev, const char *name, +struct fpga_manager *fpga_mgr_create(struct device *parent, const char *name, const struct fpga_manager_ops *mops, void *priv) { @@ -571,12 +571,12 @@ struct fpga_manager *fpga_mgr_create(struct device *dev, const char *name, if (!mops || !mops->write_complete || !mops->state || !mops->write_init || (!mops->write && !mops->write_sg) || (mops->write && mops->write_sg)) { - dev_err(dev, "Attempt to register without fpga_manager_ops\n"); + dev_err(parent, "Attempt to register without fpga_manager_ops\n"); return NULL; } if (!name || !strlen(name)) { - dev_err(dev, "Attempt to register with no name!\n"); + dev_err(parent, "Attempt to register with no name!\n"); return NULL; } @@ -597,8 +597,8 @@ struct fpga_manager *fpga_mgr_create(struct device *dev, const char *name, device_initialize(&mgr->dev); mgr->dev.class = fpga_mgr_class; mgr->dev.groups = mops->groups; - mgr->dev.parent = dev; - mgr->dev.of_node = dev->of_node; + mgr->dev.parent = parent; + mgr->dev.of_node = parent->of_node; mgr->dev.id = id; ret = dev_set_name(&mgr->dev, "fpga%d", id); @@ -636,7 +636,7 @@ static void devm_fpga_mgr_release(struct device *dev, void *res) /** * devm_fpga_mgr_create - create and initialize a managed FPGA manager struct - * @dev: fpga manager device from pdev + * @parent: fpga manager device from pdev * @name: fpga manager name * @mops: pointer to structure of fpga manager ops * @priv: fpga manager private data @@ -651,7 +651,7 @@ static void devm_fpga_mgr_release(struct device *dev, void *res) * * Return: pointer to struct fpga_manager or NULL */ -struct fpga_manager *devm_fpga_mgr_create(struct device *dev, const char *name, +struct fpga_manager *devm_fpga_mgr_create(struct device *parent, const char *name, const struct fpga_manager_ops *mops, void *priv) { @@ -661,13 +661,13 @@ struct fpga_manager *devm_fpga_mgr_create(struct device *dev, const char *name, if (!dr) return NULL; - dr->mgr = fpga_mgr_create(dev, name, mops, priv); + dr->mgr = fpga_mgr_create(parent, name, mops, priv); if (!dr->mgr) { devres_free(dr); return NULL; } - devres_add(dev, dr); + devres_add(parent, dr); return dr->mgr; } From patchwork Wed Jun 9 22:11:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Russ Weight X-Patchwork-Id: 12311343 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.0 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNWANTED_LANGUAGE_BODY, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DDA88C48BCD for ; Wed, 9 Jun 2021 22:14:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C77AA613E1 for ; Wed, 9 Jun 2021 22:14:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229931AbhFIWQp (ORCPT ); Wed, 9 Jun 2021 18:16:45 -0400 Received: from mga18.intel.com ([134.134.136.126]:22632 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229535AbhFIWQo (ORCPT ); Wed, 9 Jun 2021 18:16:44 -0400 IronPort-SDR: ii1kxKR3+Ieh/8GscXvOsTmt66/dtqZewPZFt+IbnOWVvWGI8mcy7aiJ6r8vOgpv32Ylu72zG4 68BCo94rafmQ== X-IronPort-AV: E=McAfee;i="6200,9189,10010"; a="192496216" X-IronPort-AV: E=Sophos;i="5.83,261,1616482800"; d="scan'208";a="192496216" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2021 15:14:41 -0700 IronPort-SDR: 7NatYFxQTHRMVebEsIrFrYY7i9/dvFcHr5kLGffjlodUBWMQMrgdYv6dO7A15j/aksgKqzf/cG tUw71CuNMcEA== X-IronPort-AV: E=Sophos;i="5.83,261,1616482800"; d="scan'208";a="477095326" Received: from rhweight-mobl2.amr.corp.intel.com (HELO rhweight-mobl2.ra.intel.com) ([10.251.20.114]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2021 15:14:40 -0700 From: Russ Weight To: mdf@kernel.org, linux-fpga@vger.kernel.org Cc: trix@redhat.com, lgoncalv@redhat.com, yilun.xu@intel.com, hao.wu@intel.com, matthew.gerlach@intel.com, richard.gong@intel.com, Russ Weight Subject: [PATCH v2 4/8] fpga: bridge: Rename dev to parent for parent device Date: Wed, 9 Jun 2021 15:11:31 -0700 Message-Id: <20210609221135.261837-5-russell.h.weight@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210609221135.261837-1-russell.h.weight@intel.com> References: <20210609221135.261837-1-russell.h.weight@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org Rename variable "dev" to "parent" in cases where it represents the parent device. Signed-off-by: Russ Weight Reviewed-by: Xu Yilun --- v2: - This patch contains the renaming of "dev" to "parent" that was previously part of the patch: "fpga: bridge: Use standard dev_release for class driver" --- drivers/fpga/fpga-bridge.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/fpga/fpga-bridge.c b/drivers/fpga/fpga-bridge.c index 05c6d4f2d043..6c56afc66a6d 100644 --- a/drivers/fpga/fpga-bridge.c +++ b/drivers/fpga/fpga-bridge.c @@ -313,7 +313,7 @@ ATTRIBUTE_GROUPS(fpga_bridge); /** * fpga_bridge_create - create and initialize a struct fpga_bridge - * @dev: FPGA bridge device from pdev + * @parent: FPGA bridge device from pdev * @name: FPGA bridge name * @br_ops: pointer to structure of fpga bridge ops * @priv: FPGA bridge private data @@ -323,7 +323,7 @@ ATTRIBUTE_GROUPS(fpga_bridge); * * Return: struct fpga_bridge or NULL */ -struct fpga_bridge *fpga_bridge_create(struct device *dev, const char *name, +struct fpga_bridge *fpga_bridge_create(struct device *parent, const char *name, const struct fpga_bridge_ops *br_ops, void *priv) { @@ -331,7 +331,7 @@ struct fpga_bridge *fpga_bridge_create(struct device *dev, const char *name, int id, ret; if (!name || !strlen(name)) { - dev_err(dev, "Attempt to register with no name!\n"); + dev_err(parent, "Attempt to register with no name!\n"); return NULL; } @@ -353,8 +353,8 @@ struct fpga_bridge *fpga_bridge_create(struct device *dev, const char *name, device_initialize(&bridge->dev); bridge->dev.groups = br_ops->groups; bridge->dev.class = fpga_bridge_class; - bridge->dev.parent = dev; - bridge->dev.of_node = dev->of_node; + bridge->dev.parent = parent; + bridge->dev.of_node = parent->of_node; bridge->dev.id = id; ret = dev_set_name(&bridge->dev, "br%d", id); @@ -392,7 +392,7 @@ static void devm_fpga_bridge_release(struct device *dev, void *res) /** * devm_fpga_bridge_create - create and init a managed struct fpga_bridge - * @dev: FPGA bridge device from pdev + * @parent: FPGA bridge device from pdev * @name: FPGA bridge name * @br_ops: pointer to structure of fpga bridge ops * @priv: FPGA bridge private data @@ -408,7 +408,7 @@ static void devm_fpga_bridge_release(struct device *dev, void *res) * Return: struct fpga_bridge or NULL */ struct fpga_bridge -*devm_fpga_bridge_create(struct device *dev, const char *name, +*devm_fpga_bridge_create(struct device *parent, const char *name, const struct fpga_bridge_ops *br_ops, void *priv) { struct fpga_bridge **ptr, *bridge; @@ -417,12 +417,12 @@ struct fpga_bridge if (!ptr) return NULL; - bridge = fpga_bridge_create(dev, name, br_ops, priv); + bridge = fpga_bridge_create(parent, name, br_ops, priv); if (!bridge) { devres_free(ptr); } else { *ptr = bridge; - devres_add(dev, ptr); + devres_add(parent, ptr); } return bridge; From patchwork Wed Jun 9 22:11:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Russ Weight X-Patchwork-Id: 12311341 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48426C48BDF for ; Wed, 9 Jun 2021 22:14:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 324CB613E1 for ; Wed, 9 Jun 2021 22:14:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229942AbhFIWQp (ORCPT ); Wed, 9 Jun 2021 18:16:45 -0400 Received: from mga18.intel.com ([134.134.136.126]:22626 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229740AbhFIWQo (ORCPT ); Wed, 9 Jun 2021 18:16:44 -0400 IronPort-SDR: S3zmwZQWZjGuu7JNZj+XrO/MXcoUhQmivat9ychKyyjjJTkyoVq/C9iCZBpGKb1sRZvrn8VHHU AybpCADf2mLA== X-IronPort-AV: E=McAfee;i="6200,9189,10010"; a="192496217" X-IronPort-AV: E=Sophos;i="5.83,261,1616482800"; d="scan'208";a="192496217" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2021 15:14:42 -0700 IronPort-SDR: iEFdpliOxYY7Qtg7U3fOdUrGzN/3md93jlZVuUW7P2dJMgxYlixdbPkyQIhbpdu1Q0V/9C1byR dBNF2FB0SaPA== X-IronPort-AV: E=Sophos;i="5.83,261,1616482800"; d="scan'208";a="477095332" Received: from rhweight-mobl2.amr.corp.intel.com (HELO rhweight-mobl2.ra.intel.com) ([10.251.20.114]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2021 15:14:41 -0700 From: Russ Weight To: mdf@kernel.org, linux-fpga@vger.kernel.org Cc: trix@redhat.com, lgoncalv@redhat.com, yilun.xu@intel.com, hao.wu@intel.com, matthew.gerlach@intel.com, richard.gong@intel.com, Russ Weight Subject: [PATCH v2 5/8] fpga: region: Rename dev to parent for parent device Date: Wed, 9 Jun 2021 15:11:32 -0700 Message-Id: <20210609221135.261837-6-russell.h.weight@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210609221135.261837-1-russell.h.weight@intel.com> References: <20210609221135.261837-1-russell.h.weight@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org Rename variable "dev" to "parent" in cases where it represents the parent device. Signed-off-by: Russ Weight Reviewed-by: Xu Yilun --- v2: - This patch contains the renaming of "dev" to "parent" that was previously part of the patch: "fpga: region: Use standard dev_release for class driver" --- drivers/fpga/fpga-region.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/fpga/fpga-region.c b/drivers/fpga/fpga-region.c index c3134b89c3fe..563626d66e56 100644 --- a/drivers/fpga/fpga-region.c +++ b/drivers/fpga/fpga-region.c @@ -181,7 +181,7 @@ ATTRIBUTE_GROUPS(fpga_region); /** * fpga_region_create - alloc and init a struct fpga_region - * @dev: device parent + * @parent: device parent * @mgr: manager that programs this region * @get_bridges: optional function to get bridges to a list * @@ -192,7 +192,7 @@ ATTRIBUTE_GROUPS(fpga_region); * Return: struct fpga_region or NULL */ struct fpga_region -*fpga_region_create(struct device *dev, +*fpga_region_create(struct device *parent, struct fpga_manager *mgr, int (*get_bridges)(struct fpga_region *)) { @@ -214,8 +214,8 @@ struct fpga_region device_initialize(®ion->dev); region->dev.class = fpga_region_class; - region->dev.parent = dev; - region->dev.of_node = dev->of_node; + region->dev.parent = parent; + region->dev.of_node = parent->of_node; region->dev.id = id; ret = dev_set_name(®ion->dev, "region%d", id); @@ -268,7 +268,7 @@ static void devm_fpga_region_release(struct device *dev, void *res) * Return: struct fpga_region or NULL */ struct fpga_region -*devm_fpga_region_create(struct device *dev, +*devm_fpga_region_create(struct device *parent, struct fpga_manager *mgr, int (*get_bridges)(struct fpga_region *)) { @@ -278,12 +278,12 @@ struct fpga_region if (!ptr) return NULL; - region = fpga_region_create(dev, mgr, get_bridges); + region = fpga_region_create(parent, mgr, get_bridges); if (!region) { devres_free(ptr); } else { *ptr = region; - devres_add(dev, ptr); + devres_add(parent, ptr); } return region; From patchwork Wed Jun 9 22:11:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Russ Weight X-Patchwork-Id: 12311347 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6BF8CC48BD1 for ; Wed, 9 Jun 2021 22:14:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4DE7E61377 for ; Wed, 9 Jun 2021 22:14:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229705AbhFIWQq (ORCPT ); Wed, 9 Jun 2021 18:16:46 -0400 Received: from mga18.intel.com ([134.134.136.126]:22626 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229941AbhFIWQp (ORCPT ); Wed, 9 Jun 2021 18:16:45 -0400 IronPort-SDR: WwDG5hdqOvuu19Y2/z0HpMad40Dbd0Ug0rl0cagkZttsv42m0EozZlhWnPuUIbY+/AJCoYWHHk d1d+CkWBQZtw== X-IronPort-AV: E=McAfee;i="6200,9189,10010"; a="192496220" X-IronPort-AV: E=Sophos;i="5.83,261,1616482800"; d="scan'208";a="192496220" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2021 15:14:42 -0700 IronPort-SDR: cUXJ2l064KQs4AVlbFw1pIjzeGl5RlgkG1xFIAqzNwUfnbazNIjT2P6Yc3QKcmDzficNz2LC9p bBjiCeT6ZGyw== X-IronPort-AV: E=Sophos;i="5.83,261,1616482800"; d="scan'208";a="477095335" Received: from rhweight-mobl2.amr.corp.intel.com (HELO rhweight-mobl2.ra.intel.com) ([10.251.20.114]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2021 15:14:42 -0700 From: Russ Weight To: mdf@kernel.org, linux-fpga@vger.kernel.org Cc: trix@redhat.com, lgoncalv@redhat.com, yilun.xu@intel.com, hao.wu@intel.com, matthew.gerlach@intel.com, richard.gong@intel.com, Russ Weight Subject: [PATCH v2 6/8] fpga: mgr: Use standard dev_release for class driver Date: Wed, 9 Jun 2021 15:11:33 -0700 Message-Id: <20210609221135.261837-7-russell.h.weight@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210609221135.261837-1-russell.h.weight@intel.com> References: <20210609221135.261837-1-russell.h.weight@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org The FPGA manager class driver data structure is being treated as a managed resource instead of using the class.dev_release call-back function to release the class data structure. This change populates the class.dev_release function, changes the fpga_mgr_free() function to call put_device() and changes the fpga_mgr_unregister() function to call device_del() instead of device_unregister(). Signed-off-by: Russ Weight Reviewed-by: Xu Yilun --- v2: - Moved the renaming of "dev" to "parent" to a separate patch - Call fpga_mgr_free() in devm_fpga_mgr_release() instead of put_device() --- drivers/fpga/fpga-mgr.c | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c index 42ddc0844781..9f6c3760b6ff 100644 --- a/drivers/fpga/fpga-mgr.c +++ b/drivers/fpga/fpga-mgr.c @@ -585,8 +585,10 @@ struct fpga_manager *fpga_mgr_create(struct device *parent, const char *name, return NULL; id = ida_simple_get(&fpga_mgr_ida, 0, 0, GFP_KERNEL); - if (id < 0) - goto error_kfree; + if (id < 0) { + kfree(mgr); + return NULL; + } mutex_init(&mgr->ref_mutex); @@ -602,17 +604,12 @@ struct fpga_manager *fpga_mgr_create(struct device *parent, const char *name, mgr->dev.id = id; ret = dev_set_name(&mgr->dev, "fpga%d", id); - if (ret) - goto error_device; + if (ret) { + put_device(&mgr->dev); + return NULL; + } return mgr; - -error_device: - ida_simple_remove(&fpga_mgr_ida, id); -error_kfree: - kfree(mgr); - - return NULL; } EXPORT_SYMBOL_GPL(fpga_mgr_create); @@ -622,8 +619,7 @@ EXPORT_SYMBOL_GPL(fpga_mgr_create); */ void fpga_mgr_free(struct fpga_manager *mgr) { - ida_simple_remove(&fpga_mgr_ida, mgr->dev.id); - kfree(mgr); + put_device(&mgr->dev); } EXPORT_SYMBOL_GPL(fpga_mgr_free); @@ -692,16 +688,11 @@ int fpga_mgr_register(struct fpga_manager *mgr) ret = device_add(&mgr->dev); if (ret) - goto error_device; + return ret; dev_info(&mgr->dev, "%s registered\n", mgr->name); return 0; - -error_device: - ida_simple_remove(&fpga_mgr_ida, mgr->dev.id); - - return ret; } EXPORT_SYMBOL_GPL(fpga_mgr_register); @@ -722,7 +713,7 @@ void fpga_mgr_unregister(struct fpga_manager *mgr) if (mgr->mops->fpga_remove) mgr->mops->fpga_remove(mgr); - device_unregister(&mgr->dev); + device_del(&mgr->dev); } EXPORT_SYMBOL_GPL(fpga_mgr_unregister); @@ -781,6 +772,10 @@ EXPORT_SYMBOL_GPL(devm_fpga_mgr_register); static void fpga_mgr_dev_release(struct device *dev) { + struct fpga_manager *mgr = to_fpga_manager(dev); + + ida_simple_remove(&fpga_mgr_ida, mgr->dev.id); + kfree(mgr); } static int __init fpga_mgr_class_init(void) From patchwork Wed Jun 9 22:11:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Russ Weight X-Patchwork-Id: 12311345 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 37955C48BCF for ; Wed, 9 Jun 2021 22:14:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2254F613E3 for ; Wed, 9 Jun 2021 22:14:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229740AbhFIWQp (ORCPT ); Wed, 9 Jun 2021 18:16:45 -0400 Received: from mga18.intel.com ([134.134.136.126]:22632 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229705AbhFIWQp (ORCPT ); Wed, 9 Jun 2021 18:16:45 -0400 IronPort-SDR: /crg8Oat9z3JtQn8OYt7uwKBT+eCdBJYKODKyp5Xe+ke1a0QnMPBEkW25d2gcPsREdJCYZNG4q HO9MrCIhl/rg== X-IronPort-AV: E=McAfee;i="6200,9189,10010"; a="192496222" X-IronPort-AV: E=Sophos;i="5.83,261,1616482800"; d="scan'208";a="192496222" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2021 15:14:44 -0700 IronPort-SDR: vJWkLBw2uo43mdE2RXXCialkX31S7Snq7YG//2jIAyWqwNllS8S/JEkC/5eClZuHBel0bulfZx 3gFmgEdgk/rA== X-IronPort-AV: E=Sophos;i="5.83,261,1616482800"; d="scan'208";a="477095341" Received: from rhweight-mobl2.amr.corp.intel.com (HELO rhweight-mobl2.ra.intel.com) ([10.251.20.114]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2021 15:14:43 -0700 From: Russ Weight To: mdf@kernel.org, linux-fpga@vger.kernel.org Cc: trix@redhat.com, lgoncalv@redhat.com, yilun.xu@intel.com, hao.wu@intel.com, matthew.gerlach@intel.com, richard.gong@intel.com, Russ Weight Subject: [PATCH v2 7/8] fpga: bridge: Use standard dev_release for class driver Date: Wed, 9 Jun 2021 15:11:34 -0700 Message-Id: <20210609221135.261837-8-russell.h.weight@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210609221135.261837-1-russell.h.weight@intel.com> References: <20210609221135.261837-1-russell.h.weight@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org The FPGA bridge class driver data structure is being treated as a managed resource instead of using standard dev_release call-back to release the class data structure. This change populates the class.dev_release function and changes the fpga_bridge_free() function to call put_device(). It also changes fpga_bridge_unregister() to call device_del() instead of device_unregister(). Signed-off-by: Russ Weight Reviewed-by: Xu Yilun --- v2: - Moved the renaming of "dev" to "parent" to a separate patch - Call fpga_bridge_free() in devm_fpga_bridge_release() instead of put_device() --- drivers/fpga/fpga-bridge.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/fpga/fpga-bridge.c b/drivers/fpga/fpga-bridge.c index 6c56afc66a6d..b40f4b4228e7 100644 --- a/drivers/fpga/fpga-bridge.c +++ b/drivers/fpga/fpga-bridge.c @@ -340,8 +340,10 @@ struct fpga_bridge *fpga_bridge_create(struct device *parent, const char *name, return NULL; id = ida_simple_get(&fpga_bridge_ida, 0, 0, GFP_KERNEL); - if (id < 0) - goto error_kfree; + if (id < 0) { + kfree(bridge); + return NULL; + } mutex_init(&bridge->mutex); INIT_LIST_HEAD(&bridge->node); @@ -358,17 +360,12 @@ struct fpga_bridge *fpga_bridge_create(struct device *parent, const char *name, bridge->dev.id = id; ret = dev_set_name(&bridge->dev, "br%d", id); - if (ret) - goto error_device; + if (ret) { + put_device(&bridge->dev); + return NULL; + } return bridge; - -error_device: - ida_simple_remove(&fpga_bridge_ida, id); -error_kfree: - kfree(bridge); - - return NULL; } EXPORT_SYMBOL_GPL(fpga_bridge_create); @@ -378,8 +375,7 @@ EXPORT_SYMBOL_GPL(fpga_bridge_create); */ void fpga_bridge_free(struct fpga_bridge *bridge) { - ida_simple_remove(&fpga_bridge_ida, bridge->dev.id); - kfree(bridge); + put_device(&bridge->dev); } EXPORT_SYMBOL_GPL(fpga_bridge_free); @@ -469,12 +465,16 @@ void fpga_bridge_unregister(struct fpga_bridge *bridge) if (bridge->br_ops && bridge->br_ops->fpga_bridge_remove) bridge->br_ops->fpga_bridge_remove(bridge); - device_unregister(&bridge->dev); + device_del(&bridge->dev); } EXPORT_SYMBOL_GPL(fpga_bridge_unregister); static void fpga_bridge_dev_release(struct device *dev) { + struct fpga_bridge *bridge = to_fpga_bridge(dev); + + ida_simple_remove(&fpga_bridge_ida, bridge->dev.id); + kfree(bridge); } static int __init fpga_bridge_dev_init(void) From patchwork Wed Jun 9 22:11:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Russ Weight X-Patchwork-Id: 12311349 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9D196C48BE5 for ; Wed, 9 Jun 2021 22:14:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8627B613E3 for ; Wed, 9 Jun 2021 22:14:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229941AbhFIWQr (ORCPT ); Wed, 9 Jun 2021 18:16:47 -0400 Received: from mga18.intel.com ([134.134.136.126]:22632 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229535AbhFIWQp (ORCPT ); Wed, 9 Jun 2021 18:16:45 -0400 IronPort-SDR: qCYL81gop8nssK1NUFTmxhk6WhnPoXx9roEJ/fCz+WXGNPJ3AThuQrDwjZtRK61DjCXh+4memj 60S327RFjDIA== X-IronPort-AV: E=McAfee;i="6200,9189,10010"; a="192496224" X-IronPort-AV: E=Sophos;i="5.83,261,1616482800"; d="scan'208";a="192496224" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2021 15:14:44 -0700 IronPort-SDR: nBw5Cza1AKQ3ns9FJBQLYlQXbOPpbYqXYwKgXFmx1zrauNnAGUMVXyUaLEdfbHklEsuDmtG2cU WERXK7X/ajpA== X-IronPort-AV: E=Sophos;i="5.83,261,1616482800"; d="scan'208";a="477095344" Received: from rhweight-mobl2.amr.corp.intel.com (HELO rhweight-mobl2.ra.intel.com) ([10.251.20.114]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2021 15:14:44 -0700 From: Russ Weight To: mdf@kernel.org, linux-fpga@vger.kernel.org Cc: trix@redhat.com, lgoncalv@redhat.com, yilun.xu@intel.com, hao.wu@intel.com, matthew.gerlach@intel.com, richard.gong@intel.com, Russ Weight Subject: [PATCH v2 8/8] fpga: region: Use standard dev_release for class driver Date: Wed, 9 Jun 2021 15:11:35 -0700 Message-Id: <20210609221135.261837-9-russell.h.weight@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210609221135.261837-1-russell.h.weight@intel.com> References: <20210609221135.261837-1-russell.h.weight@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org The FPGA region class driver data structure is being treated as a managed resource instead of using standard dev_release call-back to release the class data structure. This change populates the class.dev_release function and changes the fpga_region_free() function to call put_device(). It also changes fpga_region_unregister() to call device_del() instead of device_unregister(). Signed-off-by: Russ Weight Reviewed-by: Xu Yilun --- v2: - Moved the renaming of "dev" to "parent" to a separate patch - Call fpga_region_free() in devm_fpga_region_release() instead of put_device() --- drivers/fpga/fpga-region.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/fpga/fpga-region.c b/drivers/fpga/fpga-region.c index 563626d66e56..bdc15fab60c0 100644 --- a/drivers/fpga/fpga-region.c +++ b/drivers/fpga/fpga-region.c @@ -204,8 +204,10 @@ struct fpga_region return NULL; id = ida_simple_get(&fpga_region_ida, 0, 0, GFP_KERNEL); - if (id < 0) - goto err_free; + if (id < 0) { + kfree(region); + return NULL; + } region->mgr = mgr; region->get_bridges = get_bridges; @@ -219,17 +221,12 @@ struct fpga_region region->dev.id = id; ret = dev_set_name(®ion->dev, "region%d", id); - if (ret) - goto err_remove; + if (ret) { + put_device(®ion->dev); + return NULL; + } return region; - -err_remove: - ida_simple_remove(&fpga_region_ida, id); -err_free: - kfree(region); - - return NULL; } EXPORT_SYMBOL_GPL(fpga_region_create); @@ -239,8 +236,7 @@ EXPORT_SYMBOL_GPL(fpga_region_create); */ void fpga_region_free(struct fpga_region *region) { - ida_simple_remove(&fpga_region_ida, region->dev.id); - kfree(region); + put_device(®ion->dev); } EXPORT_SYMBOL_GPL(fpga_region_free); @@ -253,7 +249,7 @@ static void devm_fpga_region_release(struct device *dev, void *res) /** * devm_fpga_region_create - create and initialize a managed FPGA region struct - * @dev: device parent + * @parent: device parent * @mgr: manager that programs this region * @get_bridges: optional function to get bridges to a list * @@ -310,12 +306,16 @@ EXPORT_SYMBOL_GPL(fpga_region_register); */ void fpga_region_unregister(struct fpga_region *region) { - device_unregister(®ion->dev); + device_del(®ion->dev); } EXPORT_SYMBOL_GPL(fpga_region_unregister); static void fpga_region_dev_release(struct device *dev) { + struct fpga_region *region = to_fpga_region(dev); + + ida_simple_remove(&fpga_region_ida, region->dev.id); + kfree(region); } /**