From patchwork Mon Jun 14 17:09:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Moritz Fischer X-Patchwork-Id: 12319475 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=-17.0 required=3.0 tests=BAYES_00,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, 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 15FD6C48BE6 for ; Mon, 14 Jun 2021 17:09:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EBDC4613F0 for ; Mon, 14 Jun 2021 17:09:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235472AbhFNRL2 (ORCPT ); Mon, 14 Jun 2021 13:11:28 -0400 Received: from mail-pj1-f41.google.com ([209.85.216.41]:40822 "EHLO mail-pj1-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235470AbhFNRL1 (ORCPT ); Mon, 14 Jun 2021 13:11:27 -0400 Received: by mail-pj1-f41.google.com with SMTP id mp5-20020a17090b1905b029016dd057935fso10482551pjb.5 for ; Mon, 14 Jun 2021 10:09:24 -0700 (PDT) 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=CfADbUiO5XrTDnFfW6staI5R+wFQK6+JiA4pAz+CoVg=; b=n7Zao27HbDWi3OwDOgg1ZtRVkegSOC7rTbP9OTdA1/xqp023CV4oFvWsu+bq2qZdoQ j28tZLga0RCsSTRxVf0lT3ILHjtqmtfJKcRUbTtZVmStPg9/tH5Lq+FgZFh1U1AwE2h+ vszeyIuzkF8q3VDGYOXTOwkZTo7APdxMFGuR7EikLCT+eOoAKIupQ5q85xCYeLUEHrkl KRpLnosFnzVQf/zhFUZCyYy6cpiqptv94tKPk3DzF8l+l22ixoNBY03ZRn8v0/FIxGeY ReTIeWsgEXAXXUKmh9339mm/4tA8763viTDxfk7kDSfEeXf+J6K+aCPVaUzefydkjUkJ sH5w== X-Gm-Message-State: AOAM53374bZw8vYnlPFLtiEbRG2V55nNzWMdC/lhQDR8RQkmWUStkwwO wjXr9trP5Y/Qx/COmLgPV0dGnNHA/Vq86Q== X-Google-Smtp-Source: ABdhPJx70zpT59rCtOc5s+qlxLaTNo/1WRbAdk8GxPYXDoOObKVeTjNzPhjEC3y8FlUfx5xaC/dCvA== X-Received: by 2002:a17:90b:1511:: with SMTP id le17mr19826685pjb.137.1623690564383; Mon, 14 Jun 2021 10:09:24 -0700 (PDT) Received: from localhost ([2601:647:5b00:1161:a4cc:eef9:fbc0:2781]) by smtp.gmail.com with ESMTPSA id j13sm13028037pgp.29.2021.06.14.10.09.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jun 2021 10:09:23 -0700 (PDT) From: Moritz Fischer To: gregkh@linuxfoundation.org Cc: linux-fpga@vger.kernel.org, Moritz Fischer , Russ Weight , Xu Yilun Subject: [PATCH 1/8] fpga: altera-pr-ip: Remove function alt_pr_unregister Date: Mon, 14 Jun 2021 10:09:02 -0700 Message-Id: <20210614170909.232415-2-mdf@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210614170909.232415-1-mdf@kernel.org> References: <20210614170909.232415-1-mdf@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org From: Russ Weight Remove the alt_pr_unregister() function; it is no longer used. Signed-off-by: Russ Weight Reviewed-by: Xu Yilun Signed-off-by: Moritz Fischer --- 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 Mon Jun 14 17:09:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Moritz Fischer X-Patchwork-Id: 12319481 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=-17.0 required=3.0 tests=BAYES_00,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, 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 98F40C2B9F4 for ; Mon, 14 Jun 2021 17:09:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 85A68611CA for ; Mon, 14 Jun 2021 17:09:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235503AbhFNRLp (ORCPT ); Mon, 14 Jun 2021 13:11:45 -0400 Received: from mail-pf1-f173.google.com ([209.85.210.173]:40929 "EHLO mail-pf1-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235500AbhFNRLp (ORCPT ); Mon, 14 Jun 2021 13:11:45 -0400 Received: by mail-pf1-f173.google.com with SMTP id q25so11020340pfh.7 for ; Mon, 14 Jun 2021 10:09:26 -0700 (PDT) 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=MW9wowscZURk0RXBZlljpwSHr7tI2uW4NqHBQr/f+eY=; b=HCviIH2qZ66ARxiGBkBroLmCwRXP73/o5NJU6R182Xv8FMwIosD8FWrOCiuahu2bdG R1Sn+Mb9Qi3EURAbHakruwNx71yCRL0t5cq+TP30/cD3+hcbpvHGrvYOZUpl6fVcj74c jeReYwc+QAc34gBkkHsq0SRyfCXgeUYWH17mucY0RCBXISHPXV5b6oYxFk0ONdjSwZve dSDefjO9ZxkOJjqo5P4lrgJRSzTLrrlolw0pGdCOe8ksTzdNOpDCt/XvK49whqDWKuIR KuYO28wAHSxzlKNtDjBhjlMkphK1NdFKFFIC5qqpDcO/oMGClLC7Z1ZT9xvCHSacg5Z1 Q9yg== X-Gm-Message-State: AOAM531qAAgVMXx5M15M+nRgj4UV59hHcU/tKCJTdYL+0M6DNPjR671f KIuYxEBopByqJ3ot6Va87Hfj08gAcHKUIg== X-Google-Smtp-Source: ABdhPJycDGFaPTlJy4xXQmheh272MoYAFG4fipc0hJbt2jLpAQ3Yy5ObVhJDEsNotP0B7k8tFcDCYg== X-Received: by 2002:a63:6841:: with SMTP id d62mr18078444pgc.7.1623690565896; Mon, 14 Jun 2021 10:09:25 -0700 (PDT) Received: from localhost ([2601:647:5b00:1161:a4cc:eef9:fbc0:2781]) by smtp.gmail.com with ESMTPSA id v67sm13132820pfb.193.2021.06.14.10.09.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jun 2021 10:09:25 -0700 (PDT) From: Moritz Fischer To: gregkh@linuxfoundation.org Cc: linux-fpga@vger.kernel.org, Moritz Fischer , Russ Weight , Xu Yilun Subject: [PATCH 2/8] fpga: stratix10-soc: Add missing fpga_mgr_free() call Date: Mon, 14 Jun 2021 10:09:03 -0700 Message-Id: <20210614170909.232415-3-mdf@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210614170909.232415-1-mdf@kernel.org> References: <20210614170909.232415-1-mdf@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org From: Russ Weight 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 Signed-off-by: Moritz Fischer --- 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 Mon Jun 14 17:09:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Moritz Fischer X-Patchwork-Id: 12319477 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=-17.0 required=3.0 tests=BAYES_00,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, 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 C8AB1C2B9F4 for ; Mon, 14 Jun 2021 17:09:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ACF2961209 for ; Mon, 14 Jun 2021 17:09:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235494AbhFNRLb (ORCPT ); Mon, 14 Jun 2021 13:11:31 -0400 Received: from mail-pl1-f182.google.com ([209.85.214.182]:45595 "EHLO mail-pl1-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235485AbhFNRLa (ORCPT ); Mon, 14 Jun 2021 13:11:30 -0400 Received: by mail-pl1-f182.google.com with SMTP id 11so6911884plk.12 for ; Mon, 14 Jun 2021 10:09:27 -0700 (PDT) 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=J51T/obrOPyGovoDbxVC+XlPtDQp4fDs5hHapdvBwUQ=; b=T6FQyzPDhQEoCeU43s0YermfCuZZd1zK7pGIs8N2H0JmePnv5jrOFynDXbwUE6rRIC RIRN4Qsk3ExXR52P79aIkux3k96OMtsB7HnfjlBmAGE2NWyvZUauJjsYrznww2nQxois 8W+J2EFdh9+S7Mxp85UGYpK3vIJTH/lae4Tqtu1Q3XF3Pm00MR+h1M588zHO8Vkn7UuK G/1OURFkofkspKHXw+BuxSAsoqkBsJNeCPW8q1iNWUp/7oQz0hq8labeLSupacGMPQuB w3Tcn+MCBE0ivEVwjqg6YvTE7L+ut7G/1Dc/dZxh6lUxAotquVmKUhQU/3d9ZEmKGqRZ TUyw== X-Gm-Message-State: AOAM530BIdeZRmHK6W+wHen53YhDqmCe/RBs6+sHDhFtZ4eJAlL6TjcN pKViAwoCiVexSwiLKdRn89o= X-Google-Smtp-Source: ABdhPJz1ofeenPb7MeqGNomVR3olGcRm75QReY+latpEcF6F58+y6X1WQ/C+GImP9VC6cSMJ+SzgEQ== X-Received: by 2002:a17:90a:398f:: with SMTP id z15mr20118996pjb.183.1623690567460; Mon, 14 Jun 2021 10:09:27 -0700 (PDT) Received: from localhost ([2601:647:5b00:1161:a4cc:eef9:fbc0:2781]) by smtp.gmail.com with ESMTPSA id u7sm13767164pgl.39.2021.06.14.10.09.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jun 2021 10:09:26 -0700 (PDT) From: Moritz Fischer To: gregkh@linuxfoundation.org Cc: linux-fpga@vger.kernel.org, Moritz Fischer , Russ Weight , Xu Yilun Subject: [PATCH 3/8] fpga: mgr: Rename dev to parent for parent device Date: Mon, 14 Jun 2021 10:09:04 -0700 Message-Id: <20210614170909.232415-4-mdf@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210614170909.232415-1-mdf@kernel.org> References: <20210614170909.232415-1-mdf@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org From: Russ Weight Rename variable "dev" to "parent" in cases where it represents the parent device. Signed-off-by: Russ Weight Reviewed-by: Xu Yilun Signed-off-by: Moritz Fischer --- 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 Mon Jun 14 17:09:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Moritz Fischer X-Patchwork-Id: 12319485 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=-17.0 required=3.0 tests=BAYES_00,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, 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 57A43C2B9F4 for ; Mon, 14 Jun 2021 17:09:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 41B50611CA for ; Mon, 14 Jun 2021 17:09:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235497AbhFNRLt (ORCPT ); Mon, 14 Jun 2021 13:11:49 -0400 Received: from mail-pj1-f51.google.com ([209.85.216.51]:36721 "EHLO mail-pj1-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235485AbhFNRLr (ORCPT ); Mon, 14 Jun 2021 13:11:47 -0400 Received: by mail-pj1-f51.google.com with SMTP id s17-20020a17090a8811b029016e89654f93so5328085pjn.1 for ; Mon, 14 Jun 2021 10:09:29 -0700 (PDT) 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=QuO24i1X2z6IyYjkrN2N6FYOKq0ITn0EZx7zLWieMiE=; b=PEBeBXO+qlg8yGWQCSM+uQW/KWHTE6iJuJcbHy+VjyA9DDn25IdjN5oncB0D8XA/pe nf5EXhuJ5R3DVbDrdp1bemkBXDRpOX/qT8Y7IL11Kjn7+8Q0O9pSk+5Ocd6Uq3vbv57q xlmSriH/MxOR7OtJOutfmT8tXk+GQAKOR7iB7xL3O6ntw0Eo0Nubx1wXmvh/qvSAK26K RabQB6c6QEBiGzzcOuRQjaCoNu0fZpVAxKY2gXGRO6RE0PNpJbtQ5YPq8laysg5ELM1Q CSlsWQUuSjzi+HrkBzTK9U3G3kGcP4uN0RTRMSpHYXTVvJ0SoFQbLr6ghqcREd5QQa27 NUMQ== X-Gm-Message-State: AOAM531LA5KsOL2ynu+eODIWc2KmLChqKyqu0Yq1brlt99pl1bL/o0Gg 2gsqB1jlhNreGjJKhrvvT0w= X-Google-Smtp-Source: ABdhPJyC8HS2xWHTtcjUi+GiG2jnKfXmHKaHuNoKU5J2YrMBjZIYfCsDYfAyHKxVhu1hSJtAHXmuWw== X-Received: by 2002:a17:90a:901:: with SMTP id n1mr163591pjn.44.1623690569296; Mon, 14 Jun 2021 10:09:29 -0700 (PDT) Received: from localhost ([2601:647:5b00:1161:a4cc:eef9:fbc0:2781]) by smtp.gmail.com with ESMTPSA id d3sm13369787pfn.141.2021.06.14.10.09.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jun 2021 10:09:28 -0700 (PDT) From: Moritz Fischer To: gregkh@linuxfoundation.org Cc: linux-fpga@vger.kernel.org, Moritz Fischer , Russ Weight , Xu Yilun Subject: [PATCH 4/8] fpga: bridge: Rename dev to parent for parent device Date: Mon, 14 Jun 2021 10:09:05 -0700 Message-Id: <20210614170909.232415-5-mdf@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210614170909.232415-1-mdf@kernel.org> References: <20210614170909.232415-1-mdf@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org From: Russ Weight Rename variable "dev" to "parent" in cases where it represents the parent device. Signed-off-by: Russ Weight Reviewed-by: Xu Yilun Signed-off-by: Moritz Fischer --- 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 e9266b2a357f..d4aca0f724f5 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 Mon Jun 14 17:09:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Moritz Fischer X-Patchwork-Id: 12319487 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=-17.0 required=3.0 tests=BAYES_00,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, 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 50375C48BE8 for ; Mon, 14 Jun 2021 17:09:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3351E61185 for ; Mon, 14 Jun 2021 17:09:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235502AbhFNRLu (ORCPT ); Mon, 14 Jun 2021 13:11:50 -0400 Received: from mail-pg1-f169.google.com ([209.85.215.169]:44857 "EHLO mail-pg1-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235485AbhFNRLu (ORCPT ); Mon, 14 Jun 2021 13:11:50 -0400 Received: by mail-pg1-f169.google.com with SMTP id t13so1808454pgu.11 for ; Mon, 14 Jun 2021 10:09:31 -0700 (PDT) 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=1IKLcPLgXhbPPaHVOyD7rp4+LtK4qcz/bWQRShT4Gok=; b=A0prdY0aOEli8SstWH3pzq6JaoEC1th6kL9ievgLSllyX04MCvyzH4l8t+trFHo/g7 4dIvCt0oRCToDo6OC+I+mfUb9lp5gY3ADVw6FCDnMRzahqRtiJ53joVbAhZ8NFq3QSi7 UefNyw3FaId+XBhDtIgQ4gc98UCdH46x9rDHoQGE2G73AASs7E3WPU3SHkSQ53Tgogz/ zjse7ItNIpRl9hZyr+QGKAyI3DsqivW+nor7RoEiiUaaRreTfBjDZmDuWEwRJmScktod uBwTgBdKLnxECM6ejxrkzLjv0VOgXi4Vpl9OiiizlC9cGoJFZUFwV5jw936cvZLBx1K9 KXYw== X-Gm-Message-State: AOAM530o3C51Su7EJ38tkQhvgKblHgoFGcA4/pfl/+eYKQIMyiITT713 MgoCDf6pU8V1pXFUJnh3p34= X-Google-Smtp-Source: ABdhPJyg/JG2AqLqM29MJon3jKhHQ7TiA3vlIYphr/A1aLCSFnnOLJYh/qlNrCvN6FXrR+Eoz/INpg== X-Received: by 2002:a63:1a5b:: with SMTP id a27mr29661pgm.427.1623690570850; Mon, 14 Jun 2021 10:09:30 -0700 (PDT) Received: from localhost ([2601:647:5b00:1161:a4cc:eef9:fbc0:2781]) by smtp.gmail.com with ESMTPSA id n37sm12742163pfv.47.2021.06.14.10.09.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jun 2021 10:09:30 -0700 (PDT) From: Moritz Fischer To: gregkh@linuxfoundation.org Cc: linux-fpga@vger.kernel.org, Moritz Fischer , Russ Weight , Xu Yilun Subject: [PATCH 5/8] fpga: region: Rename dev to parent for parent device Date: Mon, 14 Jun 2021 10:09:06 -0700 Message-Id: <20210614170909.232415-6-mdf@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210614170909.232415-1-mdf@kernel.org> References: <20210614170909.232415-1-mdf@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org From: Russ Weight Rename variable "dev" to "parent" in cases where it represents the parent device. Signed-off-by: Russ Weight Reviewed-by: Xu Yilun Signed-off-by: Moritz Fischer --- drivers/fpga/fpga-region.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/fpga/fpga-region.c b/drivers/fpga/fpga-region.c index c3134b89c3fe..4d60d643cada 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); @@ -253,7 +253,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 * @@ -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 Mon Jun 14 17:09:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Moritz Fischer X-Patchwork-Id: 12319483 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=-17.0 required=3.0 tests=BAYES_00,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, 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 F1B2CC4743C for ; Mon, 14 Jun 2021 17:09:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DB86161159 for ; Mon, 14 Jun 2021 17:09:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235500AbhFNRLt (ORCPT ); Mon, 14 Jun 2021 13:11:49 -0400 Received: from mail-pl1-f176.google.com ([209.85.214.176]:45594 "EHLO mail-pl1-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235497AbhFNRLs (ORCPT ); Mon, 14 Jun 2021 13:11:48 -0400 Received: by mail-pl1-f176.google.com with SMTP id 11so6912006plk.12 for ; Mon, 14 Jun 2021 10:09:32 -0700 (PDT) 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=P8wHrGuc0HXPDKaZ6I66XrZzjraoB4R/382pU9HsLcU=; b=iEkLkl636vR5LDE4VfBx4zJZwUH2HiKR6mTM1klHb8ayeWo9s7pxt+ggKqYhXBnZ7/ RY9jrHYfCfDhBOf9OGpb9SeWGIovyq6lefVQZ4X00fgjeAxjnmGCnff/Pq+hU2kRK0Q/ CPNp3mA7xmi0mfxq7+y67sZazCYJeXfh24yI+Fq9X1Owssw7pEhWyGiY9hvbcTqL24cD BE7Cd2yLH1Q0LBy8P5hutyCqgQIuNcO2IyaEyN9bsDGA3NWvL453JtMbhgpTMxDFG4P/ 1LQRfxctPS3FPxm2Xwg1+EP0QkB/kAcWijm59pisVXa2KPU874RxjzVYtRbgSzC1e/x6 ndkw== X-Gm-Message-State: AOAM530ojNOD40LBEwlstr5OcPQm91dwn3o9Q+cMxf15L32jAjiqsNEu 6oZWVslf/dsgQ4dv3aJdB/8= X-Google-Smtp-Source: ABdhPJyxx3G1c96tEsoJkdiyb2/N5uA/uFfxEUtrboI79uaYLCySFtLo8X4BxZ9OME+OJOKOHGoDbg== X-Received: by 2002:a17:902:dac2:b029:110:994a:abc3 with SMTP id q2-20020a170902dac2b0290110994aabc3mr241234plx.78.1623690572526; Mon, 14 Jun 2021 10:09:32 -0700 (PDT) Received: from localhost ([2601:647:5b00:1161:a4cc:eef9:fbc0:2781]) by smtp.gmail.com with ESMTPSA id u4sm1648661pfu.27.2021.06.14.10.09.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jun 2021 10:09:31 -0700 (PDT) From: Moritz Fischer To: gregkh@linuxfoundation.org Cc: linux-fpga@vger.kernel.org, Moritz Fischer , Russ Weight , Xu Yilun Subject: [PATCH 6/8] fpga: mgr: Use standard dev_release for class driver Date: Mon, 14 Jun 2021 10:09:07 -0700 Message-Id: <20210614170909.232415-7-mdf@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210614170909.232415-1-mdf@kernel.org> References: <20210614170909.232415-1-mdf@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org From: Russ Weight 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 Signed-off-by: Moritz Fischer --- 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 Mon Jun 14 17:09:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Moritz Fischer X-Patchwork-Id: 12319479 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=-17.0 required=3.0 tests=BAYES_00,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, 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 EC9D5C2B9F4 for ; Mon, 14 Jun 2021 17:09:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D575861185 for ; Mon, 14 Jun 2021 17:09:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235078AbhFNRLh (ORCPT ); Mon, 14 Jun 2021 13:11:37 -0400 Received: from mail-pf1-f178.google.com ([209.85.210.178]:39583 "EHLO mail-pf1-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235485AbhFNRLh (ORCPT ); Mon, 14 Jun 2021 13:11:37 -0400 Received: by mail-pf1-f178.google.com with SMTP id k15so11019652pfp.6 for ; Mon, 14 Jun 2021 10:09:34 -0700 (PDT) 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=yYPGmANBSfZBi4amo1Bgx2OEk3jiKcjGucI1PxoeL9E=; b=gltgBI6bgjY3ehx9+x/qb9nIN8qCc56V/hbPVDl7hGDuwp0/X2nrxD8JQywI6iyI+H A+txhSRTgmm3BfsETv8MGYSBbNXOGx6j/Ghr9te7dRgYqn9vZnZVDSypV/BiiHwMIXGI jOHuzTmcmJwF8jWMcTBg8p6k9HtN9/+lQs0eejrNhU2XWC4EWt9ong8Nh96WNtQ3DnZL DuZUtmA4ERNuDpfTXSAyux4bHlmfxlVbt7ZCn5XtYFee7b/s0r7kTrM7P2pGgO6ZkZim H/BNgjb2w6W9DLD5KBsO2pW/4PC2IdaHMxKxPYVTeMtp+kKIH+vNVVeqx0pZ+nqbxdYq x0Aw== X-Gm-Message-State: AOAM530OQpirFlbFD87g1/d++pxlaUKjqoDN6qmGJRENygMuZF+Z5HWk elX/l8gzOf6Mr9cGAJwT6uk= X-Google-Smtp-Source: ABdhPJwWePqYNeZZfFQwOKbSjRcvlQU1WUl1ddDIqGHXfH4dOxR37q94NRH5ngfqgdOtsSw4P6GRIw== X-Received: by 2002:aa7:8509:0:b029:2e5:8cfe:bc17 with SMTP id v9-20020aa785090000b02902e58cfebc17mr22852330pfn.2.1623690574232; Mon, 14 Jun 2021 10:09:34 -0700 (PDT) Received: from localhost ([2601:647:5b00:1161:a4cc:eef9:fbc0:2781]) by smtp.gmail.com with ESMTPSA id y3sm9753126pgr.46.2021.06.14.10.09.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jun 2021 10:09:33 -0700 (PDT) From: Moritz Fischer To: gregkh@linuxfoundation.org Cc: linux-fpga@vger.kernel.org, Moritz Fischer , Russ Weight , Xu Yilun Subject: [PATCH 7/8] fpga: bridge: Use standard dev_release for class driver Date: Mon, 14 Jun 2021 10:09:08 -0700 Message-Id: <20210614170909.232415-8-mdf@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210614170909.232415-1-mdf@kernel.org> References: <20210614170909.232415-1-mdf@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org From: Russ Weight 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 Signed-off-by: Moritz Fischer --- 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 d4aca0f724f5..cf06c887593a 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 Mon Jun 14 17:09:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Moritz Fischer X-Patchwork-Id: 12319489 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=-17.0 required=3.0 tests=BAYES_00,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, 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 DA16FC2B9F4 for ; Mon, 14 Jun 2021 17:09:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C16FC61185 for ; Mon, 14 Jun 2021 17:09:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235485AbhFNRL4 (ORCPT ); Mon, 14 Jun 2021 13:11:56 -0400 Received: from mail-pf1-f176.google.com ([209.85.210.176]:36774 "EHLO mail-pf1-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235403AbhFNRLz (ORCPT ); Mon, 14 Jun 2021 13:11:55 -0400 Received: by mail-pf1-f176.google.com with SMTP id c12so11023528pfl.3 for ; Mon, 14 Jun 2021 10:09:36 -0700 (PDT) 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=64IvQlrXeou9jXkno2E2GgEDTZxDLn+r8yPnV7jM6oo=; b=PTFh+wR3BfMUsUFYBkD28ry8bASJiIgV2+eSB5rM44x5OHB7/sjeg3aE4/QZv7kmlg vc5Y3a7HBVwKyn0INNDnED1WanoZ61Lhv9hpviejR0dS+f7uWAkHCILOj6dWpCsYJCzP JFxXFKAh88ksDkPyc4hHdy2Pv6Yvi3Wnw7zT0RciD2hAhdLVCv5i43GeT/W3x9X35DyE xuDEzi7h/w1vCJwQQKENhlFyh1/5MPWZsUontJSSHpms8Jnmm8nNSxSMI+qFr18u3zBU xtseqdSiCmdrdojGKPiJL+hIHF8b1t433elvKMI+ySCAKVVuqmgCUk1EbHdjMzXh36Fv vE+w== X-Gm-Message-State: AOAM533dqhSRwT5c/1K1SLQ9uxgNb/v1NXhiQvrs24hQb7ipWx5QuaBd PTFzWSfjV/YOTPwFdmx42BE= X-Google-Smtp-Source: ABdhPJx5kOEjSsaSYR/Db6aGJrE6a9pEL2diVwV4qJ/d7Cqzg+CY5I86v7QtB/7EDnPBHpnKlDlddw== X-Received: by 2002:a65:624e:: with SMTP id q14mr17720484pgv.103.1623690575797; Mon, 14 Jun 2021 10:09:35 -0700 (PDT) Received: from localhost ([2601:647:5b00:1161:a4cc:eef9:fbc0:2781]) by smtp.gmail.com with ESMTPSA id 20sm12842816pfi.170.2021.06.14.10.09.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jun 2021 10:09:35 -0700 (PDT) From: Moritz Fischer To: gregkh@linuxfoundation.org Cc: linux-fpga@vger.kernel.org, Moritz Fischer , Russ Weight , Xu Yilun Subject: [PATCH 8/8] fpga: region: Use standard dev_release for class driver Date: Mon, 14 Jun 2021 10:09:09 -0700 Message-Id: <20210614170909.232415-9-mdf@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210614170909.232415-1-mdf@kernel.org> References: <20210614170909.232415-1-mdf@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org From: Russ Weight 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 Signed-off-by: Moritz Fischer --- drivers/fpga/fpga-region.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/fpga/fpga-region.c b/drivers/fpga/fpga-region.c index 4d60d643cada..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); @@ -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); } /**