[PATCH v2] ASoC: tlv320aic32x4: Fix missing error check for devm_clk_register()

Haotian Zhang posted 1 patch 11 hours ago
sound/soc/codecs/tlv320aic32x4-clk.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
[PATCH v2] ASoC: tlv320aic32x4: Fix missing error check for devm_clk_register()
Posted by Haotian Zhang 11 hours ago
aic32x4_register_clocks() ignores the return value of
aic32x4_register_clk(), which returns the result of
devm_clk_register(). This causes the driver to ignore
clock registration errors and return success even if
devm_clk_register() fails.

Check the return value of aic32x4_register_clk() and
return the error code if registration fails. The
aic32x4_probe() has already implemented the check for the
return value of aic32x4_register_clocks().

Fixes: 514b044cba66 ("ASoC: tlv320aic32x4: Model PLL in CCF")
Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
---
Changes in v2:
  - Correct the missing braces{} for the loop.
---
 sound/soc/codecs/tlv320aic32x4-clk.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/sound/soc/codecs/tlv320aic32x4-clk.c b/sound/soc/codecs/tlv320aic32x4-clk.c
index 5c0a76a4a106..663b969d6af9 100644
--- a/sound/soc/codecs/tlv320aic32x4-clk.c
+++ b/sound/soc/codecs/tlv320aic32x4-clk.c
@@ -479,6 +479,7 @@ static struct clk *aic32x4_register_clk(struct device *dev,
 int aic32x4_register_clocks(struct device *dev, const char *mclk_name)
 {
 	int i;
+	struct clk *clk;
 
 	/*
 	 * These lines are here to preserve the current functionality of
@@ -491,8 +492,11 @@ int aic32x4_register_clocks(struct device *dev, const char *mclk_name)
 	aic32x4_clkdesc_array[1].parent_names =
 			(const char *[]) { mclk_name, "bclk", "gpio", "pll" };
 
-	for (i = 0; i < ARRAY_SIZE(aic32x4_clkdesc_array); ++i)
-		aic32x4_register_clk(dev, &aic32x4_clkdesc_array[i]);
+	for (i = 0; i < ARRAY_SIZE(aic32x4_clkdesc_array); ++i) {
+		clk = aic32x4_register_clk(dev, &aic32x4_clkdesc_array[i]);
+		if (IS_ERR(clk))
+			return PTR_ERR(clk);
+	}
 
 	return 0;
 }
-- 
2.43.0