Skip to contentSkip to conversation

ASoC: es8311: Improve error handling and power

PATCH In review Hsieh Hung-En 2 participants 4 messages Apr 15 – Apr 16

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover ASoC: es8311: Improve error handling and power

This series improves the robustness of the ES8311 codec driver by checking return values of register operations and ensuring proper clock resource management.

The first patch checks regcache_sync() during resume. The second patch fixes a clock reference count leak and checks update_bits during bias level transitions.

Hsieh Hung-En (2):
ASoC: es8311: Check regcache_sync() error in resume
ASoC: es8311: Fix clock leak and check update_bits in set_bias_level()

 sound/soc/codecs/es8311.c | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/2 ASoC: es8311: Check regcache_sync() error in resume

The es8311_resume() function currently ignores the return value of regcache_sync(). If syncing the cache fails, the function still returns 0, leaving the codec in a potentially incorrect state.

Check the return value and propagate it to the ASoC core to ensure resume failures are properly handled.

---
 sound/soc/codecs/es8311.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
sound/soc/codecs/es8311.c +6 -1
index 0b07a53cc792..9e371e2d6eae 100644
@@ -862,13 +862,18 @@ static int es8311_suspend(struct snd_soc_component *component)
 static int es8311_resume(struct snd_soc_component *component)
 {
 	struct es8311_priv *es8311;
+	int ret;
 
 	es8311 = snd_soc_component_get_drvdata(component);
 
 	es8311_reset(component, false);
 
 	regcache_cache_only(es8311->regmap, false);
-	regcache_sync(es8311->regmap);
+	ret = regcache_sync(es8311->regmap);
+	if (ret) {
+		dev_err(component->dev, "unable to sync regcache\n");
+		return ret;
+	}
 
 	return 0;
 }
Signature · 1 line
2.34.1
#2 lore raw

PATCH 2/2 ASoC: es8311: Fix clock leak and check update_bits in set_bias_level()

In reply to Hsieh Hung-En

In es8311_set_bias_level(), the return value of snd_soc_component_update_bits() was ignored. If this fails, not only is the VMID selection not applied, but the previously enabled mclk is left running, leading to an unbalanced clock reference count (clock leak).

Check the return value and ensure clk_disable_unprepare() is called on failure to maintain proper resource management.

---
 sound/soc/codecs/es8311.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
sound/soc/codecs/es8311.c +10 -5
index 9e371e2d6eae..564af5c04dbb 100644
@@ -761,6 +761,7 @@ static int es8311_set_bias_level(struct snd_soc_component *component,
 {
 	struct es8311_priv *es8311 = snd_soc_component_get_drvdata(component);
 	struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component);
+	int ret;
 
 	switch (level) {
 	case SND_SOC_BIAS_ON:
@@ -769,17 +770,21 @@ static int es8311_set_bias_level(struct snd_soc_component *component,
 		break;
 	case SND_SOC_BIAS_STANDBY:
 		if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) {
-			int ret = clk_prepare_enable(es8311->mclk);
+			ret = clk_prepare_enable(es8311->mclk);
 			if (ret) {
 				dev_err(component->dev,
 					"unable to prepare mclk\n");
 				return ret;
 			}
 
-			snd_soc_component_update_bits(
-				component, ES8311_SYS3,
-				ES8311_SYS3_PDN_VMIDSEL_MASK,
-				ES8311_SYS3_PDN_VMIDSEL_STARTUP_NORMAL_SPEED);
+			ret = snd_soc_component_update_bits(
+				      component, ES8311_SYS3,
+				      ES8311_SYS3_PDN_VMIDSEL_MASK,
+				      ES8311_SYS3_PDN_VMIDSEL_STARTUP_NORMAL_SPEED);
+			if (ret < 0) {
+				clk_disable_unprepare(es8311->mclk);
+				return ret;
+			}
 		}
 
 		break;
Signature · 1 line
2.34.1
maintainer
#3 lore raw
In reply to Hsieh Hung-En
Quoted 11 lines · Hsieh Hung-En

ASoC: es8311: Improve error handling and power

This series improves the robustness of the ES8311 codec driver by checking return values of register operations and ensuring proper clock resource management.

The first patch checks regcache_sync() during resume. The second patch fixes a clock reference count leak and checks update_bits during bias level transitions.

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.1

Thanks!

[1/2] ASoC: es8311: Check regcache_sync() error in resume

      https://git.kernel.org/broonie/sound/c/37e9faf21670
[2/2] ASoC: es8311: Fix clock leak and check update_bits in set_bias_level()
      https://git.kernel.org/broonie/sound/c/c15bc1681045

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark