All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luca Ceresoli <luca@lucaceresoli.net>
To: linux-pci@vger.kernel.org
Cc: "Luca Ceresoli" <luca@lucaceresoli.net>,
	"Dan Carpenter" <dan.carpenter@oracle.com>,
	linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org,
	"Kishon Vijay Abraham I" <kishon@ti.com>,
	"Lorenzo Pieralisi" <lorenzo.pieralisi@arm.com>,
	"Rob Herring" <robh@kernel.org>,
	"Krzysztof Wilczyński" <kw@linux.com>,
	"Bjorn Helgaas" <bhelgaas@google.com>,
	"Sekhar Nori" <nsekhar@ti.com>,
	"kernel test robot" <lkp@intel.com>
Subject: [PATCH 2/2] PCI: dra7xx: Fix clk disabling in some error paths
Date: Tue, 14 Dec 2021 23:14:50 +0100	[thread overview]
Message-ID: <20211214221450.589884-2-luca@lucaceresoli.net> (raw)
In-Reply-To: <20211214221450.589884-1-luca@lucaceresoli.net>

dra7xx->clk is not disabled+unprepared in some one the error paths,
specifically devm_phy_get() fails.

Fix by moving the clk_prepare_enable() stanza after all the devm_*()
resource grabbing but before all the goto-based error management. This way
it is possible to keep the 'return err' without the need to replace it with
a new goto statement.

Fixes: 5af9405397bf ("PCI: dra7xx: Get an optional clock")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Reported-by: kernel test robot <lkp@intel.com>
Link: https://lore.kernel.org/lkml/202111301803.NOwoj4Jd-lkp@intel.com/
Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
---
 drivers/pci/controller/dwc/pci-dra7xx.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/pci/controller/dwc/pci-dra7xx.c b/drivers/pci/controller/dwc/pci-dra7xx.c
index 2ccc53869e13..d17cc088d07e 100644
--- a/drivers/pci/controller/dwc/pci-dra7xx.c
+++ b/drivers/pci/controller/dwc/pci-dra7xx.c
@@ -748,10 +748,6 @@ static int dra7xx_pcie_probe(struct platform_device *pdev)
 		return dev_err_probe(dev, PTR_ERR(dra7xx->clk),
 				     "clock request failed");
 
-	ret = clk_prepare_enable(dra7xx->clk);
-	if (ret)
-		return ret;
-
 	for (i = 0; i < phy_count; i++) {
 		snprintf(name, sizeof(name), "pcie-phy%d", i);
 		phy[i] = devm_phy_get(dev, name);
@@ -759,6 +755,10 @@ static int dra7xx_pcie_probe(struct platform_device *pdev)
 			return PTR_ERR(phy[i]);
 	}
 
+	ret = clk_prepare_enable(dra7xx->clk);
+	if (ret)
+		return ret;
+
 	for (i = 0; i < phy_count; i++) {
 		link[i] = device_link_add(dev, &phy[i]->dev, DL_FLAG_STATELESS);
 		if (!link[i]) {
-- 
2.25.1


WARNING: multiple messages have this Message-ID (diff)
From: Luca Ceresoli <luca@lucaceresoli.net>
To: linux-pci@vger.kernel.org
Cc: "Luca Ceresoli" <luca@lucaceresoli.net>,
	"Dan Carpenter" <dan.carpenter@oracle.com>,
	linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org,
	"Kishon Vijay Abraham I" <kishon@ti.com>,
	"Lorenzo Pieralisi" <lorenzo.pieralisi@arm.com>,
	"Rob Herring" <robh@kernel.org>,
	"Krzysztof Wilczyński" <kw@linux.com>,
	"Bjorn Helgaas" <bhelgaas@google.com>,
	"Sekhar Nori" <nsekhar@ti.com>,
	"kernel test robot" <lkp@intel.com>
Subject: [PATCH 2/2] PCI: dra7xx: Fix clk disabling in some error paths
Date: Tue, 14 Dec 2021 23:14:50 +0100	[thread overview]
Message-ID: <20211214221450.589884-2-luca@lucaceresoli.net> (raw)
In-Reply-To: <20211214221450.589884-1-luca@lucaceresoli.net>

dra7xx->clk is not disabled+unprepared in some one the error paths,
specifically devm_phy_get() fails.

Fix by moving the clk_prepare_enable() stanza after all the devm_*()
resource grabbing but before all the goto-based error management. This way
it is possible to keep the 'return err' without the need to replace it with
a new goto statement.

Fixes: 5af9405397bf ("PCI: dra7xx: Get an optional clock")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Reported-by: kernel test robot <lkp@intel.com>
Link: https://lore.kernel.org/lkml/202111301803.NOwoj4Jd-lkp@intel.com/
Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
---
 drivers/pci/controller/dwc/pci-dra7xx.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/pci/controller/dwc/pci-dra7xx.c b/drivers/pci/controller/dwc/pci-dra7xx.c
index 2ccc53869e13..d17cc088d07e 100644
--- a/drivers/pci/controller/dwc/pci-dra7xx.c
+++ b/drivers/pci/controller/dwc/pci-dra7xx.c
@@ -748,10 +748,6 @@ static int dra7xx_pcie_probe(struct platform_device *pdev)
 		return dev_err_probe(dev, PTR_ERR(dra7xx->clk),
 				     "clock request failed");
 
-	ret = clk_prepare_enable(dra7xx->clk);
-	if (ret)
-		return ret;
-
 	for (i = 0; i < phy_count; i++) {
 		snprintf(name, sizeof(name), "pcie-phy%d", i);
 		phy[i] = devm_phy_get(dev, name);
@@ -759,6 +755,10 @@ static int dra7xx_pcie_probe(struct platform_device *pdev)
 			return PTR_ERR(phy[i]);
 	}
 
+	ret = clk_prepare_enable(dra7xx->clk);
+	if (ret)
+		return ret;
+
 	for (i = 0; i < phy_count; i++) {
 		link[i] = device_link_add(dev, &phy[i]->dev, DL_FLAG_STATELESS);
 		if (!link[i]) {
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2021-12-14 22:15 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-14 22:14 [PATCH 1/2] PCI: dra7xx: Fix link removal on probe error Luca Ceresoli
2021-12-14 22:14 ` Luca Ceresoli
2021-12-14 22:14 ` Luca Ceresoli [this message]
2021-12-14 22:14   ` [PATCH 2/2] PCI: dra7xx: Fix clk disabling in some error paths Luca Ceresoli
2021-12-14 22:42 ` [PATCH 1/2] PCI: dra7xx: Fix link removal on probe error Rob Herring
2021-12-14 22:42   ` Rob Herring
2021-12-16  9:08   ` Luca Ceresoli
2021-12-16  9:08     ` Luca Ceresoli
2022-01-11 10:35     ` Luca Ceresoli
2022-01-11 10:35       ` Luca Ceresoli
2022-01-15 16:02       ` Rob Herring
2022-01-15 16:02         ` Rob Herring
2022-05-11 16:41         ` Lorenzo Pieralisi
2022-05-11 16:41           ` Lorenzo Pieralisi
2022-05-12 14:07           ` Luca Ceresoli
2022-05-12 14:07             ` Luca Ceresoli
2022-05-14  3:46             ` Saravana Kannan
2022-05-14  3:46               ` Saravana Kannan
2022-05-17  7:32               ` Luca Ceresoli
2022-05-17  7:32                 ` Luca Ceresoli
2022-05-19 20:25                 ` Saravana Kannan
2022-05-19 20:25                   ` Saravana Kannan
2022-05-23 13:28                   ` Luca Ceresoli
2022-05-23 13:28                     ` Luca Ceresoli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211214221450.589884-2-luca@lucaceresoli.net \
    --to=luca@lucaceresoli.net \
    --cc=bhelgaas@google.com \
    --cc=dan.carpenter@oracle.com \
    --cc=kishon@ti.com \
    --cc=kw@linux.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=nsekhar@ti.com \
    --cc=robh@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.