diff mbox

PCI: rockchip: Handle return value of clk_prepare_enable

Message ID 4ebfc69644f9d6e9e5ff0cfc82e9efa5c476be0e.1496312348.git.arvind.yadav.cs@gmail.com (mailing list archive)
State New, archived
Delegated to: Bjorn Helgaas
Headers show

Commit Message

Arvind Yadav June 1, 2017, 10:21 a.m. UTC
clk_prepare_enable() can fail here and we must check its return value.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
---
 drivers/pci/host/pcie-rockchip.c | 34 ++++++++++++++++++++++++++++------
 1 file changed, 28 insertions(+), 6 deletions(-)

Comments

Shawn Lin June 2, 2017, 7:28 a.m. UTC | #1
Hi,

在 2017/6/1 18:21, Arvind Yadav 写道:
> clk_prepare_enable() can fail here and we must check its return value.
> 
> Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>

Acked-by: Shawn Lin <shawn.lin@rock-chips.com>

> ---
>   drivers/pci/host/pcie-rockchip.c | 34 ++++++++++++++++++++++++++++------
>   1 file changed, 28 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/pci/host/pcie-rockchip.c b/drivers/pci/host/pcie-rockchip.c
> index 0e020b6..0a248cd 100644
> --- a/drivers/pci/host/pcie-rockchip.c
> +++ b/drivers/pci/host/pcie-rockchip.c
> @@ -1259,24 +1259,46 @@ static int __maybe_unused rockchip_pcie_resume_noirq(struct device *dev)
>   	struct rockchip_pcie *rockchip = dev_get_drvdata(dev);
>   	int err;
>   
> -	clk_prepare_enable(rockchip->clk_pcie_pm);
> -	clk_prepare_enable(rockchip->hclk_pcie);
> -	clk_prepare_enable(rockchip->aclk_perf_pcie);
> -	clk_prepare_enable(rockchip->aclk_pcie);
> +	err = clk_prepare_enable(rockchip->clk_pcie_pm);
> +	if (err)
> +		goto err_pcie_pm;
> +
> +	err = clk_prepare_enable(rockchip->hclk_pcie);
> +	if (err)
> +		goto err_hclk_pcie;
> +
> +	err = clk_prepare_enable(rockchip->aclk_perf_pcie);
> +	if (err)
> +		goto err_aclk_perf_pcie;
> +
> +	err = clk_prepare_enable(rockchip->aclk_pcie);
> +	if (err)
> +		goto err_aclk_pcie;
>   
>   	err = rockchip_pcie_init_port(rockchip);
>   	if (err)
> -		return err;
> +		goto err_pcie_resume;
>   
>   	err = rockchip_cfg_atu(rockchip);
>   	if (err)
> -		return err;
> +		goto err_pcie_resume;
>   
>   	/* Need this to enter L1 again */
>   	rockchip_pcie_update_txcredit_mui(rockchip);
>   	rockchip_pcie_enable_interrupts(rockchip);
>   
>   	return 0;
> +
> +err_pcie_resume:
> +	clk_disable_unprepare(rockchip->aclk_pcie);
> +err_aclk_pcie:
> +	clk_disable_unprepare(rockchip->aclk_perf_pcie);
> +err_aclk_perf_pcie:
> +	clk_disable_unprepare(rockchip->hclk_pcie);
> +err_hclk_pcie:
> +	clk_disable_unprepare(rockchip->clk_pcie_pm);
> +err_pcie_pm:
> +	return err;
>   }
>   
>   static int rockchip_pcie_probe(struct platform_device *pdev)
>
Heiko Stuebner June 2, 2017, 8:34 a.m. UTC | #2
Am Donnerstag, 1. Juni 2017, 15:51:45 CEST schrieb Arvind Yadav:
> clk_prepare_enable() can fail here and we must check its return value.
> 
> Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>

looks good, but you may want to include 
Bjorn Helgaas <bhelgaas@google.com>

who is the maintainer of the pci subsystem and would be the one
to apply your patch.

Aynway, the patch itself looks good to me
Reviewed-by: Heiko Stuebner <heiko@sntech.de>

Cheers
Heiko

> ---
>  drivers/pci/host/pcie-rockchip.c | 34 ++++++++++++++++++++++++++++------
>  1 file changed, 28 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/pci/host/pcie-rockchip.c b/drivers/pci/host/pcie-rockchip.c
> index 0e020b6..0a248cd 100644
> --- a/drivers/pci/host/pcie-rockchip.c
> +++ b/drivers/pci/host/pcie-rockchip.c
> @@ -1259,24 +1259,46 @@ static int __maybe_unused rockchip_pcie_resume_noirq(struct device *dev)
>  	struct rockchip_pcie *rockchip = dev_get_drvdata(dev);
>  	int err;
>  
> -	clk_prepare_enable(rockchip->clk_pcie_pm);
> -	clk_prepare_enable(rockchip->hclk_pcie);
> -	clk_prepare_enable(rockchip->aclk_perf_pcie);
> -	clk_prepare_enable(rockchip->aclk_pcie);
> +	err = clk_prepare_enable(rockchip->clk_pcie_pm);
> +	if (err)
> +		goto err_pcie_pm;
> +
> +	err = clk_prepare_enable(rockchip->hclk_pcie);
> +	if (err)
> +		goto err_hclk_pcie;
> +
> +	err = clk_prepare_enable(rockchip->aclk_perf_pcie);
> +	if (err)
> +		goto err_aclk_perf_pcie;
> +
> +	err = clk_prepare_enable(rockchip->aclk_pcie);
> +	if (err)
> +		goto err_aclk_pcie;
>  
>  	err = rockchip_pcie_init_port(rockchip);
>  	if (err)
> -		return err;
> +		goto err_pcie_resume;
>  
>  	err = rockchip_cfg_atu(rockchip);
>  	if (err)
> -		return err;
> +		goto err_pcie_resume;
>  
>  	/* Need this to enter L1 again */
>  	rockchip_pcie_update_txcredit_mui(rockchip);
>  	rockchip_pcie_enable_interrupts(rockchip);
>  
>  	return 0;
> +
> +err_pcie_resume:
> +	clk_disable_unprepare(rockchip->aclk_pcie);
> +err_aclk_pcie:
> +	clk_disable_unprepare(rockchip->aclk_perf_pcie);
> +err_aclk_perf_pcie:
> +	clk_disable_unprepare(rockchip->hclk_pcie);
> +err_hclk_pcie:
> +	clk_disable_unprepare(rockchip->clk_pcie_pm);
> +err_pcie_pm:
> +	return err;
>  }
>  
>  static int rockchip_pcie_probe(struct platform_device *pdev)
>
Bjorn Helgaas June 15, 2017, 9:48 p.m. UTC | #3
On Thu, Jun 01, 2017 at 03:51:45PM +0530, Arvind Yadav wrote:
> clk_prepare_enable() can fail here and we must check its return value.
> 
> Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>

Applied with ack/reviewed-by from Shawn and Heiko to pci/host-rockchip for
v4.13, thanks!

I had to apply it manually because of other changes in the same area, so it
would be good if you could check it over.

https://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git/commit/?h=pci/host-rockchip&id=45f8ce937bc2e06e040f1118f64783b54ade7363

> ---
>  drivers/pci/host/pcie-rockchip.c | 34 ++++++++++++++++++++++++++++------
>  1 file changed, 28 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/pci/host/pcie-rockchip.c b/drivers/pci/host/pcie-rockchip.c
> index 0e020b6..0a248cd 100644
> --- a/drivers/pci/host/pcie-rockchip.c
> +++ b/drivers/pci/host/pcie-rockchip.c
> @@ -1259,24 +1259,46 @@ static int __maybe_unused rockchip_pcie_resume_noirq(struct device *dev)
>  	struct rockchip_pcie *rockchip = dev_get_drvdata(dev);
>  	int err;
>  
> -	clk_prepare_enable(rockchip->clk_pcie_pm);
> -	clk_prepare_enable(rockchip->hclk_pcie);
> -	clk_prepare_enable(rockchip->aclk_perf_pcie);
> -	clk_prepare_enable(rockchip->aclk_pcie);
> +	err = clk_prepare_enable(rockchip->clk_pcie_pm);
> +	if (err)
> +		goto err_pcie_pm;
> +
> +	err = clk_prepare_enable(rockchip->hclk_pcie);
> +	if (err)
> +		goto err_hclk_pcie;
> +
> +	err = clk_prepare_enable(rockchip->aclk_perf_pcie);
> +	if (err)
> +		goto err_aclk_perf_pcie;
> +
> +	err = clk_prepare_enable(rockchip->aclk_pcie);
> +	if (err)
> +		goto err_aclk_pcie;
>  
>  	err = rockchip_pcie_init_port(rockchip);
>  	if (err)
> -		return err;
> +		goto err_pcie_resume;
>  
>  	err = rockchip_cfg_atu(rockchip);
>  	if (err)
> -		return err;
> +		goto err_pcie_resume;
>  
>  	/* Need this to enter L1 again */
>  	rockchip_pcie_update_txcredit_mui(rockchip);
>  	rockchip_pcie_enable_interrupts(rockchip);
>  
>  	return 0;
> +
> +err_pcie_resume:
> +	clk_disable_unprepare(rockchip->aclk_pcie);
> +err_aclk_pcie:
> +	clk_disable_unprepare(rockchip->aclk_perf_pcie);
> +err_aclk_perf_pcie:
> +	clk_disable_unprepare(rockchip->hclk_pcie);
> +err_hclk_pcie:
> +	clk_disable_unprepare(rockchip->clk_pcie_pm);
> +err_pcie_pm:
> +	return err;
>  }
>  
>  static int rockchip_pcie_probe(struct platform_device *pdev)
> -- 
> 1.9.1
>
diff mbox

Patch

diff --git a/drivers/pci/host/pcie-rockchip.c b/drivers/pci/host/pcie-rockchip.c
index 0e020b6..0a248cd 100644
--- a/drivers/pci/host/pcie-rockchip.c
+++ b/drivers/pci/host/pcie-rockchip.c
@@ -1259,24 +1259,46 @@  static int __maybe_unused rockchip_pcie_resume_noirq(struct device *dev)
 	struct rockchip_pcie *rockchip = dev_get_drvdata(dev);
 	int err;
 
-	clk_prepare_enable(rockchip->clk_pcie_pm);
-	clk_prepare_enable(rockchip->hclk_pcie);
-	clk_prepare_enable(rockchip->aclk_perf_pcie);
-	clk_prepare_enable(rockchip->aclk_pcie);
+	err = clk_prepare_enable(rockchip->clk_pcie_pm);
+	if (err)
+		goto err_pcie_pm;
+
+	err = clk_prepare_enable(rockchip->hclk_pcie);
+	if (err)
+		goto err_hclk_pcie;
+
+	err = clk_prepare_enable(rockchip->aclk_perf_pcie);
+	if (err)
+		goto err_aclk_perf_pcie;
+
+	err = clk_prepare_enable(rockchip->aclk_pcie);
+	if (err)
+		goto err_aclk_pcie;
 
 	err = rockchip_pcie_init_port(rockchip);
 	if (err)
-		return err;
+		goto err_pcie_resume;
 
 	err = rockchip_cfg_atu(rockchip);
 	if (err)
-		return err;
+		goto err_pcie_resume;
 
 	/* Need this to enter L1 again */
 	rockchip_pcie_update_txcredit_mui(rockchip);
 	rockchip_pcie_enable_interrupts(rockchip);
 
 	return 0;
+
+err_pcie_resume:
+	clk_disable_unprepare(rockchip->aclk_pcie);
+err_aclk_pcie:
+	clk_disable_unprepare(rockchip->aclk_perf_pcie);
+err_aclk_perf_pcie:
+	clk_disable_unprepare(rockchip->hclk_pcie);
+err_hclk_pcie:
+	clk_disable_unprepare(rockchip->clk_pcie_pm);
+err_pcie_pm:
+	return err;
 }
 
 static int rockchip_pcie_probe(struct platform_device *pdev)