diff mbox series

[2/3] clk: lmk04832: Don't disable vco clock on probe fail

Message ID 20230802064100.15793-2-mike.looijmans@topic.nl (mailing list archive)
State Accepted, archived
Headers show
Series [1/3] clk: lmk04832: Set missing parent_names for output clocks | expand

Commit Message

Mike Looijmans Aug. 2, 2023, 6:40 a.m. UTC
The probe() method never calls clk_prepare_enable(), so it should not
call clk_disable_unprepare() for the vco.clk in the error path. Fixes
a "lmk-vco already disabled" BUG when probe fails.

Signed-off-by: Mike Looijmans <mike.looijmans@topic.nl>
---
 drivers/clk/clk-lmk04832.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

Comments

Liam Beguin Aug. 23, 2023, 7:14 p.m. UTC | #1
On Wed, Aug 02, 2023 at 08:40:59AM +0200, Mike Looijmans wrote:
> The probe() method never calls clk_prepare_enable(), so it should not
> call clk_disable_unprepare() for the vco.clk in the error path. Fixes
> a "lmk-vco already disabled" BUG when probe fails.
> 
> Signed-off-by: Mike Looijmans <mike.looijmans@topic.nl>

Reviewed-by: Liam Beguin <liambeguin@gmail.com>

> ---
>  drivers/clk/clk-lmk04832.c | 11 ++++-------
>  1 file changed, 4 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/clk/clk-lmk04832.c b/drivers/clk/clk-lmk04832.c
> index 188085e7a30b..dd1f0c59ee71 100644
> --- a/drivers/clk/clk-lmk04832.c
> +++ b/drivers/clk/clk-lmk04832.c
> @@ -1505,21 +1505,21 @@ static int lmk04832_probe(struct spi_device *spi)
>  		ret = clk_set_rate(lmk->vco.clk, lmk->vco_rate);
>  		if (ret) {
>  			dev_err(lmk->dev, "failed to set VCO rate\n");
> -			goto err_disable_vco;
> +			goto err_disable_oscin;
>  		}
>  	}
>  
>  	ret = lmk04832_register_sclk(lmk);
>  	if (ret) {
>  		dev_err(lmk->dev, "failed to init SYNC/SYSREF clock path\n");
> -		goto err_disable_vco;
> +		goto err_disable_oscin;
>  	}
>  
>  	for (i = 0; i < info->num_channels; i++) {
>  		ret = lmk04832_register_clkout(lmk, i);
>  		if (ret) {
>  			dev_err(lmk->dev, "failed to register clk %d\n", i);
> -			goto err_disable_vco;
> +			goto err_disable_oscin;
>  		}
>  	}
>  
> @@ -1528,16 +1528,13 @@ static int lmk04832_probe(struct spi_device *spi)
>  					  lmk->clk_data);
>  	if (ret) {
>  		dev_err(lmk->dev, "failed to add provider (%d)\n", ret);
> -		goto err_disable_vco;
> +		goto err_disable_oscin;
>  	}
>  
>  	spi_set_drvdata(spi, lmk);
>  
>  	return 0;
>  
> -err_disable_vco:
> -	clk_disable_unprepare(lmk->vco.clk);
> -
>  err_disable_oscin:
>  	clk_disable_unprepare(lmk->oscin);
>  
> -- 
> 2.17.1
> 
> 
> Met vriendelijke groet / kind regards,
> 
> Mike Looijmans
> System Expert
> 
> 
> TOPIC Embedded Products B.V.
> Materiaalweg 4, 5681 RJ Best
> The Netherlands
> 
> T: +31 (0) 499 33 69 69
> E: mike.looijmans@topicproducts.com
> W: www.topic.nl
> 
> Please consider the environment before printing this e-mail
Stephen Boyd Aug. 23, 2023, 10:48 p.m. UTC | #2
Quoting Mike Looijmans (2023-08-01 23:40:59)
> The probe() method never calls clk_prepare_enable(), so it should not
> call clk_disable_unprepare() for the vco.clk in the error path. Fixes
> a "lmk-vco already disabled" BUG when probe fails.
> 
> Signed-off-by: Mike Looijmans <mike.looijmans@topic.nl>
> ---

Applied to clk-next
diff mbox series

Patch

diff --git a/drivers/clk/clk-lmk04832.c b/drivers/clk/clk-lmk04832.c
index 188085e7a30b..dd1f0c59ee71 100644
--- a/drivers/clk/clk-lmk04832.c
+++ b/drivers/clk/clk-lmk04832.c
@@ -1505,21 +1505,21 @@  static int lmk04832_probe(struct spi_device *spi)
 		ret = clk_set_rate(lmk->vco.clk, lmk->vco_rate);
 		if (ret) {
 			dev_err(lmk->dev, "failed to set VCO rate\n");
-			goto err_disable_vco;
+			goto err_disable_oscin;
 		}
 	}
 
 	ret = lmk04832_register_sclk(lmk);
 	if (ret) {
 		dev_err(lmk->dev, "failed to init SYNC/SYSREF clock path\n");
-		goto err_disable_vco;
+		goto err_disable_oscin;
 	}
 
 	for (i = 0; i < info->num_channels; i++) {
 		ret = lmk04832_register_clkout(lmk, i);
 		if (ret) {
 			dev_err(lmk->dev, "failed to register clk %d\n", i);
-			goto err_disable_vco;
+			goto err_disable_oscin;
 		}
 	}
 
@@ -1528,16 +1528,13 @@  static int lmk04832_probe(struct spi_device *spi)
 					  lmk->clk_data);
 	if (ret) {
 		dev_err(lmk->dev, "failed to add provider (%d)\n", ret);
-		goto err_disable_vco;
+		goto err_disable_oscin;
 	}
 
 	spi_set_drvdata(spi, lmk);
 
 	return 0;
 
-err_disable_vco:
-	clk_disable_unprepare(lmk->vco.clk);
-
 err_disable_oscin:
 	clk_disable_unprepare(lmk->oscin);