* [PATCH] PCI: stm32: clean up some error handling in probe()
@ 2025-09-05 8:04 Dan Carpenter
2025-09-05 15:53 ` Christian Bruel
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2025-09-05 8:04 UTC (permalink / raw)
To: Christian Bruel
Cc: Lorenzo Pieralisi, Krzysztof Wilczyński,
Manivannan Sadhasivam, Rob Herring, Bjorn Helgaas,
Maxime Coquelin, Alexandre Torgue, linux-pci, linux-stm32,
linux-arm-kernel, linux-kernel, kernel-janitors
Smatch complains that the other error paths use gotos to clean up and
these two don't. Generally, the implication with that warning is that
the error handly has been ommitted. In this case, the error handling is
fine, but we can avoid a bit of code duplication by using gotos to clean
up.
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
drivers/pci/controller/dwc/pcie-stm32.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/drivers/pci/controller/dwc/pcie-stm32.c b/drivers/pci/controller/dwc/pcie-stm32.c
index 964fa6f674c8..96a5fb893af4 100644
--- a/drivers/pci/controller/dwc/pcie-stm32.c
+++ b/drivers/pci/controller/dwc/pcie-stm32.c
@@ -287,18 +287,16 @@ static int stm32_pcie_probe(struct platform_device *pdev)
ret = pm_runtime_set_active(dev);
if (ret < 0) {
- clk_disable_unprepare(stm32_pcie->clk);
- stm32_remove_pcie_port(stm32_pcie);
- return dev_err_probe(dev, ret, "Failed to activate runtime PM\n");
+ dev_err_probe(dev, ret, "Failed to activate runtime PM\n");
+ goto err_disable_clk;
}
pm_runtime_no_callbacks(dev);
ret = devm_pm_runtime_enable(dev);
if (ret < 0) {
- clk_disable_unprepare(stm32_pcie->clk);
- stm32_remove_pcie_port(stm32_pcie);
- return dev_err_probe(dev, ret, "Failed to enable runtime PM\n");
+ dev_err_probe(dev, ret, "Failed to enable runtime PM\n");
+ goto err_disable_clk;
}
ret = dw_pcie_host_init(&stm32_pcie->pci.pp);
--
2.47.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] PCI: stm32: clean up some error handling in probe()
2025-09-05 8:04 [PATCH] PCI: stm32: clean up some error handling in probe() Dan Carpenter
@ 2025-09-05 15:53 ` Christian Bruel
0 siblings, 0 replies; 2+ messages in thread
From: Christian Bruel @ 2025-09-05 15:53 UTC (permalink / raw)
To: Dan Carpenter
Cc: Lorenzo Pieralisi, Krzysztof Wilczyński,
Manivannan Sadhasivam, Rob Herring, Bjorn Helgaas,
Maxime Coquelin, Alexandre Torgue, linux-pci, linux-stm32,
linux-arm-kernel, linux-kernel, kernel-janitors
On 9/5/25 10:04, Dan Carpenter wrote:
> Smatch complains that the other error paths use gotos to clean up and
> these two don't. Generally, the implication with that warning is that
> the error handly has been ommitted. In this case, the error handling is
> fine, but we can avoid a bit of code duplication by using gotos to clean
> up.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
> drivers/pci/controller/dwc/pcie-stm32.c | 10 ++++------
> 1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/pci/controller/dwc/pcie-stm32.c b/drivers/pci/controller/dwc/pcie-stm32.c
> index 964fa6f674c8..96a5fb893af4 100644
> --- a/drivers/pci/controller/dwc/pcie-stm32.c
> +++ b/drivers/pci/controller/dwc/pcie-stm32.c
> @@ -287,18 +287,16 @@ static int stm32_pcie_probe(struct platform_device *pdev)
>
> ret = pm_runtime_set_active(dev);
> if (ret < 0) {
> - clk_disable_unprepare(stm32_pcie->clk);
> - stm32_remove_pcie_port(stm32_pcie);
> - return dev_err_probe(dev, ret, "Failed to activate runtime PM\n");
> + dev_err_probe(dev, ret, "Failed to activate runtime PM\n");
> + goto err_disable_clk;
> }
>
> pm_runtime_no_callbacks(dev);
>
> ret = devm_pm_runtime_enable(dev);
> if (ret < 0) {
> - clk_disable_unprepare(stm32_pcie->clk);
> - stm32_remove_pcie_port(stm32_pcie);
> - return dev_err_probe(dev, ret, "Failed to enable runtime PM\n");
> + dev_err_probe(dev, ret, "Failed to enable runtime PM\n");
> + goto err_disable_clk;
> }
>
> ret = dw_pcie_host_init(&stm32_pcie->pci.pp);
Acked-by: Christian Bruel <christian.bruel@foss.st.com>
thank you
Christian
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-09-05 15:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-05 8:04 [PATCH] PCI: stm32: clean up some error handling in probe() Dan Carpenter
2025-09-05 15:53 ` Christian Bruel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox