diff mbox series

[v2] ASoC: fsi: Add check for clk_enable

Message ID 20220302030900.46341-1-jiasheng@iscas.ac.cn (mailing list archive)
State Superseded
Headers show
Series [v2] ASoC: fsi: Add check for clk_enable | expand

Commit Message

Jiasheng Jiang March 2, 2022, 3:09 a.m. UTC
As the potential failure of the clk_enable(),
it should be better to check it and return error
if fails.

Fixes: ab6f6d85210c ("ASoC: fsi: add master clock control functions")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
---
Changelog:

v1 -> v2

* Change 1. Seperate the error handler.
---
 sound/soc/sh/fsi.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

Comments

Kuninori Morimoto March 2, 2022, 4:35 a.m. UTC | #1
Hi Jiasheng

Thank you for your patch

> As the potential failure of the clk_enable(),
> it should be better to check it and return error
> if fails.
> 
> Fixes: ab6f6d85210c ("ASoC: fsi: add master clock control functions")
> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
(snip)
> +		if (ret)
> +			goto err;
> +		ret = clk_enable(clock->ick);
> +		if (ret)
> +			goto disable_xck;
> +		ret = clk_enable(clock->div);
> +		if (ret)
> +			goto disable_ick;
>
>  		clock->count++;
>  	}
>  
>  	return ret;
> +
> +disable_xck:
> +	clk_disable(clock->xck);
> +disable_ick:
> +	clk_disable(clock->ick);
> +err:
> +	return ret;
>  }

I think disable_ick() / disable_xck() order are inverted ?

Thank you for your help !!

Best regards
---
Kuninori Morimoto
diff mbox series

Patch

diff --git a/sound/soc/sh/fsi.c b/sound/soc/sh/fsi.c
index cdf3b7f69ba7..91050478844a 100644
--- a/sound/soc/sh/fsi.c
+++ b/sound/soc/sh/fsi.c
@@ -816,14 +816,27 @@  static int fsi_clk_enable(struct device *dev,
 			return ret;
 		}
 
-		clk_enable(clock->xck);
-		clk_enable(clock->ick);
-		clk_enable(clock->div);
+		ret = clk_enable(clock->xck);
+		if (ret)
+			goto err;
+		ret = clk_enable(clock->ick);
+		if (ret)
+			goto disable_xck;
+		ret = clk_enable(clock->div);
+		if (ret)
+			goto disable_ick;
 
 		clock->count++;
 	}
 
 	return ret;
+
+disable_xck:
+	clk_disable(clock->xck);
+disable_ick:
+	clk_disable(clock->ick);
+err:
+	return ret;
 }
 
 static int fsi_clk_disable(struct device *dev,