* [PATCH 0/3] ASoC: es8328: Fix deemph control and improve error handling
@ 2026-01-29 17:47 Hsieh Hung-En
2026-01-29 17:47 ` [PATCH 1/3] ASoC: es8328: Fix DAC deemphasis control handling Hsieh Hung-En
` (3 more replies)
0 siblings, 4 replies; 12+ messages in thread
From: Hsieh Hung-En @ 2026-01-29 17:47 UTC (permalink / raw)
To: Mark Brown, linux-sound
Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Kuninori Morimoto,
Charles Keepax, Nicolas Frattaroli, Hsieh Hung-En
This series improves the ES8328 codec driver's reliability by ensuring that
register I/O operations and state transitions properly propagate error
codes.
It also fixes a DAC deemphasis control sequencing bug and adds proper
resource unwinding during system resume.
Summary of changes:
- Fix DAC deemphasis control: update cached state before hardware.
- Propagate error codes in set_bias_level().
- Add proper unwind handling in resume().
- Check return values of snd_soc_component_update_bits() in set_dai_fmt().
Hsieh Hung-En (3):
ASoC: es8328: Fix DAC deemphasis control handling
ASoC: es8328: Propagate errors in set_bias_level()
ASoC: es8328: Check errors in set_dai_fmt() and resume()
sound/soc/codecs/es8328.c | 116 ++++++++++++++++++++++++--------------
1 file changed, 73 insertions(+), 43 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 12+ messages in thread* [PATCH 1/3] ASoC: es8328: Fix DAC deemphasis control handling 2026-01-29 17:47 [PATCH 0/3] ASoC: es8328: Fix deemph control and improve error handling Hsieh Hung-En @ 2026-01-29 17:47 ` Hsieh Hung-En 2026-01-29 17:47 ` [PATCH 2/3] ASoC: es8328: Propagate errors in set_bias_level() Hsieh Hung-En ` (2 subsequent siblings) 3 siblings, 0 replies; 12+ messages in thread From: Hsieh Hung-En @ 2026-01-29 17:47 UTC (permalink / raw) To: Mark Brown, linux-sound Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Kuninori Morimoto, Charles Keepax, Nicolas Frattaroli, Hsieh Hung-En The DAC deemphasis control updated the hardware before updating the cached state, causing the previous setting to be applied. Update the cached deemphasis state first and then apply the setting. Also check and propagate errors from es8328_set_deemph() in hw_params(). Signed-off-by: Hsieh Hung-En <hungen3108@gmail.com> --- sound/soc/codecs/es8328.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/es8328.c b/sound/soc/codecs/es8328.c index 38340f292282..46868b7924a0 100644 --- a/sound/soc/codecs/es8328.c +++ b/sound/soc/codecs/es8328.c @@ -163,12 +163,11 @@ static int es8328_put_deemph(struct snd_kcontrol *kcontrol, if (es8328->deemph == deemph) return 0; + es8328->deemph = deemph; ret = es8328_set_deemph(component); if (ret < 0) return ret; - es8328->deemph = deemph; - return 1; } @@ -530,7 +529,9 @@ static int es8328_hw_params(struct snd_pcm_substream *substream, return ret; es8328->playback_fs = params_rate(params); - es8328_set_deemph(component); + ret = es8328_set_deemph(component); + if (ret < 0) + return ret; } else { ret = snd_soc_component_update_bits(component, ES8328_ADCCONTROL4, ES8328_ADCCONTROL4_ADCWL_MASK, -- 2.34.1 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 2/3] ASoC: es8328: Propagate errors in set_bias_level() 2026-01-29 17:47 [PATCH 0/3] ASoC: es8328: Fix deemph control and improve error handling Hsieh Hung-En 2026-01-29 17:47 ` [PATCH 1/3] ASoC: es8328: Fix DAC deemphasis control handling Hsieh Hung-En @ 2026-01-29 17:47 ` Hsieh Hung-En 2026-01-29 17:47 ` [PATCH 3/3] ASoC: es8328: Check errors in set_dai_fmt() and resume() Hsieh Hung-En 2026-01-30 16:00 ` [PATCH v2 0/5] ASoC: es8328: error handling and resume fixes Hsieh Hung-En 3 siblings, 0 replies; 12+ messages in thread From: Hsieh Hung-En @ 2026-01-29 17:47 UTC (permalink / raw) To: Mark Brown, linux-sound Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Kuninori Morimoto, Charles Keepax, Nicolas Frattaroli, Hsieh Hung-En Register writes and updates in set_bias_level() ignored return values, potentially masking I/O failures during bias level transitions. Check and propagate errors from component register writes and updates. Signed-off-by: Hsieh Hung-En <hungen3108@gmail.com> --- sound/soc/codecs/es8328.c | 60 ++++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 23 deletions(-) diff --git a/sound/soc/codecs/es8328.c b/sound/soc/codecs/es8328.c index 46868b7924a0..98fc798ff565 100644 --- a/sound/soc/codecs/es8328.c +++ b/sound/soc/codecs/es8328.c @@ -647,6 +647,7 @@ static int es8328_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); + int ret; switch (level) { case SND_SOC_BIAS_ON: @@ -654,43 +655,56 @@ static int es8328_set_bias_level(struct snd_soc_component *component, case SND_SOC_BIAS_PREPARE: /* VREF, VMID=2x50k, digital enabled */ - snd_soc_component_write(component, ES8328_CHIPPOWER, 0); - snd_soc_component_update_bits(component, ES8328_CONTROL1, - ES8328_CONTROL1_VMIDSEL_MASK | - ES8328_CONTROL1_ENREF, - ES8328_CONTROL1_VMIDSEL_50k | - ES8328_CONTROL1_ENREF); + ret = snd_soc_component_write(component, ES8328_CHIPPOWER, 0); + if (ret < 0) + return ret; + + ret = snd_soc_component_update_bits(component, ES8328_CONTROL1, + ES8328_CONTROL1_VMIDSEL_MASK | + ES8328_CONTROL1_ENREF, + ES8328_CONTROL1_VMIDSEL_50k | + ES8328_CONTROL1_ENREF); + if (ret < 0) + return ret; break; case SND_SOC_BIAS_STANDBY: if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { - snd_soc_component_update_bits(component, ES8328_CONTROL1, - ES8328_CONTROL1_VMIDSEL_MASK | - ES8328_CONTROL1_ENREF, - ES8328_CONTROL1_VMIDSEL_5k | - ES8328_CONTROL1_ENREF); + ret = snd_soc_component_update_bits(component, ES8328_CONTROL1, + ES8328_CONTROL1_VMIDSEL_MASK | + ES8328_CONTROL1_ENREF, + ES8328_CONTROL1_VMIDSEL_5k | + ES8328_CONTROL1_ENREF); + if (ret < 0) + return ret; /* Charge caps */ msleep(100); } - snd_soc_component_write(component, ES8328_CONTROL2, - ES8328_CONTROL2_OVERCURRENT_ON | - ES8328_CONTROL2_THERMAL_SHUTDOWN_ON); + ret = snd_soc_component_write(component, ES8328_CONTROL2, + ES8328_CONTROL2_OVERCURRENT_ON | + ES8328_CONTROL2_THERMAL_SHUTDOWN_ON); + if (ret < 0) + return ret; /* VREF, VMID=2*500k, digital stopped */ - snd_soc_component_update_bits(component, ES8328_CONTROL1, - ES8328_CONTROL1_VMIDSEL_MASK | - ES8328_CONTROL1_ENREF, - ES8328_CONTROL1_VMIDSEL_500k | - ES8328_CONTROL1_ENREF); + ret = snd_soc_component_update_bits(component, ES8328_CONTROL1, + ES8328_CONTROL1_VMIDSEL_MASK | + ES8328_CONTROL1_ENREF, + ES8328_CONTROL1_VMIDSEL_500k | + ES8328_CONTROL1_ENREF); + if (ret < 0) + return ret; break; case SND_SOC_BIAS_OFF: - snd_soc_component_update_bits(component, ES8328_CONTROL1, - ES8328_CONTROL1_VMIDSEL_MASK | - ES8328_CONTROL1_ENREF, - 0); + ret = snd_soc_component_update_bits(component, ES8328_CONTROL1, + ES8328_CONTROL1_VMIDSEL_MASK | + ES8328_CONTROL1_ENREF, + 0); + if (ret < 0) + return ret; break; } return 0; -- 2.34.1 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 3/3] ASoC: es8328: Check errors in set_dai_fmt() and resume() 2026-01-29 17:47 [PATCH 0/3] ASoC: es8328: Fix deemph control and improve error handling Hsieh Hung-En 2026-01-29 17:47 ` [PATCH 1/3] ASoC: es8328: Fix DAC deemphasis control handling Hsieh Hung-En 2026-01-29 17:47 ` [PATCH 2/3] ASoC: es8328: Propagate errors in set_bias_level() Hsieh Hung-En @ 2026-01-29 17:47 ` Hsieh Hung-En 2026-01-29 18:02 ` Mark Brown 2026-01-30 16:00 ` [PATCH v2 0/5] ASoC: es8328: error handling and resume fixes Hsieh Hung-En 3 siblings, 1 reply; 12+ messages in thread From: Hsieh Hung-En @ 2026-01-29 17:47 UTC (permalink / raw) To: Mark Brown, linux-sound Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Kuninori Morimoto, Charles Keepax, Nicolas Frattaroli, Hsieh Hung-En Check and propagate errors from register updates in es8328_set_dai_fmt(). Also use the cached private regmap in resume() and add proper unwind for clock/regulator enable and regcache sync failures. Signed-off-by: Hsieh Hung-En <hungen3108@gmail.com> --- sound/soc/codecs/es8328.c | 49 +++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/sound/soc/codecs/es8328.c b/sound/soc/codecs/es8328.c index 98fc798ff565..9838fe42cb6f 100644 --- a/sound/soc/codecs/es8328.c +++ b/sound/soc/codecs/es8328.c @@ -592,21 +592,26 @@ static int es8328_set_dai_fmt(struct snd_soc_dai *codec_dai, { struct snd_soc_component *component = codec_dai->component; struct es8328_priv *es8328 = snd_soc_component_get_drvdata(component); + int ret; u8 dac_mode = 0; u8 adc_mode = 0; switch (fmt & SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK) { case SND_SOC_DAIFMT_CBP_CFP: /* Master serial port mode, with BCLK generated automatically */ - snd_soc_component_update_bits(component, ES8328_MASTERMODE, - ES8328_MASTERMODE_MSC, - ES8328_MASTERMODE_MSC); + ret = snd_soc_component_update_bits(component, ES8328_MASTERMODE, + ES8328_MASTERMODE_MSC, + ES8328_MASTERMODE_MSC); + if (ret < 0) + return ret; es8328->provider = true; break; case SND_SOC_DAIFMT_CBC_CFC: /* Slave serial port mode */ - snd_soc_component_update_bits(component, ES8328_MASTERMODE, - ES8328_MASTERMODE_MSC, 0); + ret = snd_soc_component_update_bits(component, ES8328_MASTERMODE, + ES8328_MASTERMODE_MSC, 0); + if (ret < 0) + return ret; es8328->provider = false; break; default: @@ -635,10 +640,17 @@ static int es8328_set_dai_fmt(struct snd_soc_dai *codec_dai, if ((fmt & SND_SOC_DAIFMT_INV_MASK) != SND_SOC_DAIFMT_NB_NF) return -EINVAL; - snd_soc_component_update_bits(component, ES8328_DACCONTROL1, - ES8328_DACCONTROL1_DACFORMAT_MASK, dac_mode); - snd_soc_component_update_bits(component, ES8328_ADCCONTROL4, - ES8328_ADCCONTROL4_ADCFORMAT_MASK, adc_mode); + ret = snd_soc_component_update_bits(component, ES8328_DACCONTROL1, + ES8328_DACCONTROL1_DACFORMAT_MASK, + dac_mode); + if (ret < 0) + return ret; + + ret = snd_soc_component_update_bits(component, ES8328_ADCCONTROL4, + ES8328_ADCCONTROL4_ADCFORMAT_MASK, + adc_mode); + if (ret < 0) + return ret; return 0; } @@ -759,12 +771,9 @@ static int es8328_suspend(struct snd_soc_component *component) static int es8328_resume(struct snd_soc_component *component) { - struct regmap *regmap = dev_get_regmap(component->dev, NULL); - struct es8328_priv *es8328; + struct es8328_priv *es8328 = snd_soc_component_get_drvdata(component); int ret; - es8328 = snd_soc_component_get_drvdata(component); - ret = clk_prepare_enable(es8328->clk); if (ret) { dev_err(component->dev, "unable to enable clock\n"); @@ -775,17 +784,23 @@ static int es8328_resume(struct snd_soc_component *component) es8328->supplies); if (ret) { dev_err(component->dev, "unable to enable regulators\n"); - return ret; + goto err_clk; } - regcache_mark_dirty(regmap); - ret = regcache_sync(regmap); + regcache_mark_dirty(es8328->regmap); + ret = regcache_sync(es8328->regmap); if (ret) { dev_err(component->dev, "unable to sync regcache\n"); - return ret; + goto err_regulators; } return 0; + +err_regulators: + regulator_bulk_disable(ARRAY_SIZE(es8328->supplies), es8328->supplies); +err_clk: + clk_disable_unprepare(es8328->clk); + return ret; } static int es8328_component_probe(struct snd_soc_component *component) -- 2.34.1 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] ASoC: es8328: Check errors in set_dai_fmt() and resume() 2026-01-29 17:47 ` [PATCH 3/3] ASoC: es8328: Check errors in set_dai_fmt() and resume() Hsieh Hung-En @ 2026-01-29 18:02 ` Mark Brown 0 siblings, 0 replies; 12+ messages in thread From: Mark Brown @ 2026-01-29 18:02 UTC (permalink / raw) To: Hsieh Hung-En Cc: linux-sound, Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Kuninori Morimoto, Charles Keepax, Nicolas Frattaroli [-- Attachment #1: Type: text/plain, Size: 340 bytes --] On Fri, Jan 30, 2026 at 01:47:33AM +0800, Hsieh Hung-En wrote: > Check and propagate errors from register updates in es8328_set_dai_fmt(). > Also use the cached private regmap in resume() and add proper unwind for > clock/regulator enable and regcache sync failures. These are separate changes and should be split at least three patches. [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 488 bytes --] ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v2 0/5] ASoC: es8328: error handling and resume fixes 2026-01-29 17:47 [PATCH 0/3] ASoC: es8328: Fix deemph control and improve error handling Hsieh Hung-En ` (2 preceding siblings ...) 2026-01-29 17:47 ` [PATCH 3/3] ASoC: es8328: Check errors in set_dai_fmt() and resume() Hsieh Hung-En @ 2026-01-30 16:00 ` Hsieh Hung-En 2026-01-30 16:00 ` [PATCH v2 1/5] ASoC: es8328: Fix DAC deemphasis control handling Hsieh Hung-En ` (5 more replies) 3 siblings, 6 replies; 12+ messages in thread From: Hsieh Hung-En @ 2026-01-30 16:00 UTC (permalink / raw) To: Mark Brown, linux-sound Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Kuninori Morimoto, Charles Keepax, Nicolas Frattaroli, Hsieh Hung-En This is v2 of the es8328 robustness series. Changes since v1: - Split the previous "set_dai_fmt() and resume()" patch into three patches: * Check and propagate errors in set_dai_fmt() * Use cached regmap on resume for regcache sync * Add error unwind in resume to avoid leaking enabled resources No functional changes intended beyond improving reviewability by splitting the patch. Hsieh Hung-En (5): ASoC: es8328: Fix DAC deemphasis control handling ASoC: es8328: Propagate errors in set_bias_level() ASoC: es8328: Check errors in set_dai_fmt() ASoC: es8328: Use cached regmap on resume ASoC: es8328: Add error unwind in resume sound/soc/codecs/es8328.c | 116 ++++++++++++++++++++++++-------------- 1 file changed, 73 insertions(+), 43 deletions(-) -- 2.34.1 ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v2 1/5] ASoC: es8328: Fix DAC deemphasis control handling 2026-01-30 16:00 ` [PATCH v2 0/5] ASoC: es8328: error handling and resume fixes Hsieh Hung-En @ 2026-01-30 16:00 ` Hsieh Hung-En 2026-01-30 16:00 ` [PATCH v2 2/5] ASoC: es8328: Propagate errors in set_bias_level() Hsieh Hung-En ` (4 subsequent siblings) 5 siblings, 0 replies; 12+ messages in thread From: Hsieh Hung-En @ 2026-01-30 16:00 UTC (permalink / raw) To: Mark Brown, linux-sound Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Kuninori Morimoto, Charles Keepax, Nicolas Frattaroli, Hsieh Hung-En The DAC deemphasis control updated the hardware before updating the cached state, causing the previous setting to be applied. Update the cached deemphasis state first and then apply the setting. Also check and propagate errors from es8328_set_deemph() in hw_params(). Signed-off-by: Hsieh Hung-En <hungen3108@gmail.com> --- sound/soc/codecs/es8328.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/es8328.c b/sound/soc/codecs/es8328.c index 38340f292282..46868b7924a0 100644 --- a/sound/soc/codecs/es8328.c +++ b/sound/soc/codecs/es8328.c @@ -163,12 +163,11 @@ static int es8328_put_deemph(struct snd_kcontrol *kcontrol, if (es8328->deemph == deemph) return 0; + es8328->deemph = deemph; ret = es8328_set_deemph(component); if (ret < 0) return ret; - es8328->deemph = deemph; - return 1; } @@ -530,7 +529,9 @@ static int es8328_hw_params(struct snd_pcm_substream *substream, return ret; es8328->playback_fs = params_rate(params); - es8328_set_deemph(component); + ret = es8328_set_deemph(component); + if (ret < 0) + return ret; } else { ret = snd_soc_component_update_bits(component, ES8328_ADCCONTROL4, ES8328_ADCCONTROL4_ADCWL_MASK, -- 2.34.1 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v2 2/5] ASoC: es8328: Propagate errors in set_bias_level() 2026-01-30 16:00 ` [PATCH v2 0/5] ASoC: es8328: error handling and resume fixes Hsieh Hung-En 2026-01-30 16:00 ` [PATCH v2 1/5] ASoC: es8328: Fix DAC deemphasis control handling Hsieh Hung-En @ 2026-01-30 16:00 ` Hsieh Hung-En 2026-01-30 16:00 ` [PATCH v2 3/5] ASoC: es8328: Check errors in set_dai_fmt() Hsieh Hung-En ` (3 subsequent siblings) 5 siblings, 0 replies; 12+ messages in thread From: Hsieh Hung-En @ 2026-01-30 16:00 UTC (permalink / raw) To: Mark Brown, linux-sound Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Kuninori Morimoto, Charles Keepax, Nicolas Frattaroli, Hsieh Hung-En Register writes and updates in set_bias_level() ignored return values, potentially masking I/O failures during bias level transitions. Check and propagate errors from component register writes and updates. Signed-off-by: Hsieh Hung-En <hungen3108@gmail.com> --- sound/soc/codecs/es8328.c | 60 ++++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 23 deletions(-) diff --git a/sound/soc/codecs/es8328.c b/sound/soc/codecs/es8328.c index 46868b7924a0..98fc798ff565 100644 --- a/sound/soc/codecs/es8328.c +++ b/sound/soc/codecs/es8328.c @@ -647,6 +647,7 @@ static int es8328_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); + int ret; switch (level) { case SND_SOC_BIAS_ON: @@ -654,43 +655,56 @@ static int es8328_set_bias_level(struct snd_soc_component *component, case SND_SOC_BIAS_PREPARE: /* VREF, VMID=2x50k, digital enabled */ - snd_soc_component_write(component, ES8328_CHIPPOWER, 0); - snd_soc_component_update_bits(component, ES8328_CONTROL1, - ES8328_CONTROL1_VMIDSEL_MASK | - ES8328_CONTROL1_ENREF, - ES8328_CONTROL1_VMIDSEL_50k | - ES8328_CONTROL1_ENREF); + ret = snd_soc_component_write(component, ES8328_CHIPPOWER, 0); + if (ret < 0) + return ret; + + ret = snd_soc_component_update_bits(component, ES8328_CONTROL1, + ES8328_CONTROL1_VMIDSEL_MASK | + ES8328_CONTROL1_ENREF, + ES8328_CONTROL1_VMIDSEL_50k | + ES8328_CONTROL1_ENREF); + if (ret < 0) + return ret; break; case SND_SOC_BIAS_STANDBY: if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { - snd_soc_component_update_bits(component, ES8328_CONTROL1, - ES8328_CONTROL1_VMIDSEL_MASK | - ES8328_CONTROL1_ENREF, - ES8328_CONTROL1_VMIDSEL_5k | - ES8328_CONTROL1_ENREF); + ret = snd_soc_component_update_bits(component, ES8328_CONTROL1, + ES8328_CONTROL1_VMIDSEL_MASK | + ES8328_CONTROL1_ENREF, + ES8328_CONTROL1_VMIDSEL_5k | + ES8328_CONTROL1_ENREF); + if (ret < 0) + return ret; /* Charge caps */ msleep(100); } - snd_soc_component_write(component, ES8328_CONTROL2, - ES8328_CONTROL2_OVERCURRENT_ON | - ES8328_CONTROL2_THERMAL_SHUTDOWN_ON); + ret = snd_soc_component_write(component, ES8328_CONTROL2, + ES8328_CONTROL2_OVERCURRENT_ON | + ES8328_CONTROL2_THERMAL_SHUTDOWN_ON); + if (ret < 0) + return ret; /* VREF, VMID=2*500k, digital stopped */ - snd_soc_component_update_bits(component, ES8328_CONTROL1, - ES8328_CONTROL1_VMIDSEL_MASK | - ES8328_CONTROL1_ENREF, - ES8328_CONTROL1_VMIDSEL_500k | - ES8328_CONTROL1_ENREF); + ret = snd_soc_component_update_bits(component, ES8328_CONTROL1, + ES8328_CONTROL1_VMIDSEL_MASK | + ES8328_CONTROL1_ENREF, + ES8328_CONTROL1_VMIDSEL_500k | + ES8328_CONTROL1_ENREF); + if (ret < 0) + return ret; break; case SND_SOC_BIAS_OFF: - snd_soc_component_update_bits(component, ES8328_CONTROL1, - ES8328_CONTROL1_VMIDSEL_MASK | - ES8328_CONTROL1_ENREF, - 0); + ret = snd_soc_component_update_bits(component, ES8328_CONTROL1, + ES8328_CONTROL1_VMIDSEL_MASK | + ES8328_CONTROL1_ENREF, + 0); + if (ret < 0) + return ret; break; } return 0; -- 2.34.1 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v2 3/5] ASoC: es8328: Check errors in set_dai_fmt() 2026-01-30 16:00 ` [PATCH v2 0/5] ASoC: es8328: error handling and resume fixes Hsieh Hung-En 2026-01-30 16:00 ` [PATCH v2 1/5] ASoC: es8328: Fix DAC deemphasis control handling Hsieh Hung-En 2026-01-30 16:00 ` [PATCH v2 2/5] ASoC: es8328: Propagate errors in set_bias_level() Hsieh Hung-En @ 2026-01-30 16:00 ` Hsieh Hung-En 2026-01-30 16:00 ` [PATCH v2 4/5] ASoC: es8328: Use cached regmap on resume Hsieh Hung-En ` (2 subsequent siblings) 5 siblings, 0 replies; 12+ messages in thread From: Hsieh Hung-En @ 2026-01-30 16:00 UTC (permalink / raw) To: Mark Brown, linux-sound Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Kuninori Morimoto, Charles Keepax, Nicolas Frattaroli, Hsieh Hung-En Check and propagate return values from snd_soc_component_update_bits() in es8328_set_dai_fmt(). This avoids silent failures when register updates fail and ensures the DAI format is not left in an inconsistent state. Signed-off-by: Hsieh Hung-En <hungen3108@gmail.com> --- sound/soc/codecs/es8328.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/sound/soc/codecs/es8328.c b/sound/soc/codecs/es8328.c index 98fc798ff565..a18c3fe22da5 100644 --- a/sound/soc/codecs/es8328.c +++ b/sound/soc/codecs/es8328.c @@ -592,21 +592,26 @@ static int es8328_set_dai_fmt(struct snd_soc_dai *codec_dai, { struct snd_soc_component *component = codec_dai->component; struct es8328_priv *es8328 = snd_soc_component_get_drvdata(component); + int ret; u8 dac_mode = 0; u8 adc_mode = 0; switch (fmt & SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK) { case SND_SOC_DAIFMT_CBP_CFP: /* Master serial port mode, with BCLK generated automatically */ - snd_soc_component_update_bits(component, ES8328_MASTERMODE, - ES8328_MASTERMODE_MSC, - ES8328_MASTERMODE_MSC); + ret = snd_soc_component_update_bits(component, ES8328_MASTERMODE, + ES8328_MASTERMODE_MSC, + ES8328_MASTERMODE_MSC); + if (ret < 0) + return ret; es8328->provider = true; break; case SND_SOC_DAIFMT_CBC_CFC: /* Slave serial port mode */ - snd_soc_component_update_bits(component, ES8328_MASTERMODE, - ES8328_MASTERMODE_MSC, 0); + ret = snd_soc_component_update_bits(component, ES8328_MASTERMODE, + ES8328_MASTERMODE_MSC, 0); + if (ret < 0) + return ret; es8328->provider = false; break; default: @@ -635,10 +640,17 @@ static int es8328_set_dai_fmt(struct snd_soc_dai *codec_dai, if ((fmt & SND_SOC_DAIFMT_INV_MASK) != SND_SOC_DAIFMT_NB_NF) return -EINVAL; - snd_soc_component_update_bits(component, ES8328_DACCONTROL1, - ES8328_DACCONTROL1_DACFORMAT_MASK, dac_mode); - snd_soc_component_update_bits(component, ES8328_ADCCONTROL4, - ES8328_ADCCONTROL4_ADCFORMAT_MASK, adc_mode); + ret = snd_soc_component_update_bits(component, ES8328_DACCONTROL1, + ES8328_DACCONTROL1_DACFORMAT_MASK, + dac_mode); + if (ret < 0) + return ret; + + ret = snd_soc_component_update_bits(component, ES8328_ADCCONTROL4, + ES8328_ADCCONTROL4_ADCFORMAT_MASK, + adc_mode); + if (ret < 0) + return ret; return 0; } -- 2.34.1 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v2 4/5] ASoC: es8328: Use cached regmap on resume 2026-01-30 16:00 ` [PATCH v2 0/5] ASoC: es8328: error handling and resume fixes Hsieh Hung-En ` (2 preceding siblings ...) 2026-01-30 16:00 ` [PATCH v2 3/5] ASoC: es8328: Check errors in set_dai_fmt() Hsieh Hung-En @ 2026-01-30 16:00 ` Hsieh Hung-En 2026-01-30 16:00 ` [PATCH v2 5/5] ASoC: es8328: Add error unwind in resume Hsieh Hung-En 2026-02-03 12:05 ` [PATCH v2 0/5] ASoC: es8328: error handling and resume fixes Mark Brown 5 siblings, 0 replies; 12+ messages in thread From: Hsieh Hung-En @ 2026-01-30 16:00 UTC (permalink / raw) To: Mark Brown, linux-sound Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Kuninori Morimoto, Charles Keepax, Nicolas Frattaroli, Hsieh Hung-En Use the regmap stored in the driver private data when restoring the register cache on resume, instead of looking it up from the device. This keeps the resume path consistent with the regmap instance used by the driver and avoids relying on a separate dev_get_regmap() lookup. Signed-off-by: Hsieh Hung-En <hungen3108@gmail.com> --- sound/soc/codecs/es8328.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/sound/soc/codecs/es8328.c b/sound/soc/codecs/es8328.c index a18c3fe22da5..7afc97c62587 100644 --- a/sound/soc/codecs/es8328.c +++ b/sound/soc/codecs/es8328.c @@ -771,12 +771,9 @@ static int es8328_suspend(struct snd_soc_component *component) static int es8328_resume(struct snd_soc_component *component) { - struct regmap *regmap = dev_get_regmap(component->dev, NULL); - struct es8328_priv *es8328; + struct es8328_priv *es8328 = snd_soc_component_get_drvdata(component); int ret; - es8328 = snd_soc_component_get_drvdata(component); - ret = clk_prepare_enable(es8328->clk); if (ret) { dev_err(component->dev, "unable to enable clock\n"); @@ -790,8 +787,8 @@ static int es8328_resume(struct snd_soc_component *component) return ret; } - regcache_mark_dirty(regmap); - ret = regcache_sync(regmap); + regcache_mark_dirty(es8328->regmap); + ret = regcache_sync(es8328->regmap); if (ret) { dev_err(component->dev, "unable to sync regcache\n"); return ret; -- 2.34.1 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v2 5/5] ASoC: es8328: Add error unwind in resume 2026-01-30 16:00 ` [PATCH v2 0/5] ASoC: es8328: error handling and resume fixes Hsieh Hung-En ` (3 preceding siblings ...) 2026-01-30 16:00 ` [PATCH v2 4/5] ASoC: es8328: Use cached regmap on resume Hsieh Hung-En @ 2026-01-30 16:00 ` Hsieh Hung-En 2026-02-03 12:05 ` [PATCH v2 0/5] ASoC: es8328: error handling and resume fixes Mark Brown 5 siblings, 0 replies; 12+ messages in thread From: Hsieh Hung-En @ 2026-01-30 16:00 UTC (permalink / raw) To: Mark Brown, linux-sound Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Kuninori Morimoto, Charles Keepax, Nicolas Frattaroli, Hsieh Hung-En Handle failures in the resume path by unwinding previously enabled resources. If enabling regulators or syncing the regcache fails, disable regulators and unprepare the clock to avoid leaking resources and leaving the device in a partially resumed state. Signed-off-by: Hsieh Hung-En <hungen3108@gmail.com> --- sound/soc/codecs/es8328.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/es8328.c b/sound/soc/codecs/es8328.c index 7afc97c62587..9838fe42cb6f 100644 --- a/sound/soc/codecs/es8328.c +++ b/sound/soc/codecs/es8328.c @@ -784,17 +784,23 @@ static int es8328_resume(struct snd_soc_component *component) es8328->supplies); if (ret) { dev_err(component->dev, "unable to enable regulators\n"); - return ret; + goto err_clk; } regcache_mark_dirty(es8328->regmap); ret = regcache_sync(es8328->regmap); if (ret) { dev_err(component->dev, "unable to sync regcache\n"); - return ret; + goto err_regulators; } return 0; + +err_regulators: + regulator_bulk_disable(ARRAY_SIZE(es8328->supplies), es8328->supplies); +err_clk: + clk_disable_unprepare(es8328->clk); + return ret; } static int es8328_component_probe(struct snd_soc_component *component) -- 2.34.1 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v2 0/5] ASoC: es8328: error handling and resume fixes 2026-01-30 16:00 ` [PATCH v2 0/5] ASoC: es8328: error handling and resume fixes Hsieh Hung-En ` (4 preceding siblings ...) 2026-01-30 16:00 ` [PATCH v2 5/5] ASoC: es8328: Add error unwind in resume Hsieh Hung-En @ 2026-02-03 12:05 ` Mark Brown 5 siblings, 0 replies; 12+ messages in thread From: Mark Brown @ 2026-02-03 12:05 UTC (permalink / raw) To: linux-sound, Hsieh Hung-En Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Kuninori Morimoto, Charles Keepax, Nicolas Frattaroli On Sat, 31 Jan 2026 00:00:12 +0800, Hsieh Hung-En wrote: > This is v2 of the es8328 robustness series. > > Changes since v1: > - Split the previous "set_dai_fmt() and resume()" patch into three patches: > * Check and propagate errors in set_dai_fmt() > * Use cached regmap on resume for regcache sync > * Add error unwind in resume to avoid leaking enabled resources > > [...] Applied to https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next Thanks! [1/5] ASoC: es8328: Fix DAC deemphasis control handling commit: 4c6b74d58766ce7cd66ae8e14babf877039adef6 [2/5] ASoC: es8328: Propagate errors in set_bias_level() commit: 0801a03a317b4848ca8c10a98f9b84028b7c8fc6 [3/5] ASoC: es8328: Check errors in set_dai_fmt() commit: 3570e8eef217e60178d23eb490a34d64249bee45 [4/5] ASoC: es8328: Use cached regmap on resume commit: 9917d99f44231b531a1c704bbbd58059e78c2f59 [5/5] ASoC: es8328: Add error unwind in resume commit: 8232e6079ae6f8d3a61d87973cb427385aa469b9 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 ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2026-02-03 12:05 UTC | newest] Thread overview: 12+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-01-29 17:47 [PATCH 0/3] ASoC: es8328: Fix deemph control and improve error handling Hsieh Hung-En 2026-01-29 17:47 ` [PATCH 1/3] ASoC: es8328: Fix DAC deemphasis control handling Hsieh Hung-En 2026-01-29 17:47 ` [PATCH 2/3] ASoC: es8328: Propagate errors in set_bias_level() Hsieh Hung-En 2026-01-29 17:47 ` [PATCH 3/3] ASoC: es8328: Check errors in set_dai_fmt() and resume() Hsieh Hung-En 2026-01-29 18:02 ` Mark Brown 2026-01-30 16:00 ` [PATCH v2 0/5] ASoC: es8328: error handling and resume fixes Hsieh Hung-En 2026-01-30 16:00 ` [PATCH v2 1/5] ASoC: es8328: Fix DAC deemphasis control handling Hsieh Hung-En 2026-01-30 16:00 ` [PATCH v2 2/5] ASoC: es8328: Propagate errors in set_bias_level() Hsieh Hung-En 2026-01-30 16:00 ` [PATCH v2 3/5] ASoC: es8328: Check errors in set_dai_fmt() Hsieh Hung-En 2026-01-30 16:00 ` [PATCH v2 4/5] ASoC: es8328: Use cached regmap on resume Hsieh Hung-En 2026-01-30 16:00 ` [PATCH v2 5/5] ASoC: es8328: Add error unwind in resume Hsieh Hung-En 2026-02-03 12:05 ` [PATCH v2 0/5] ASoC: es8328: error handling and resume fixes Mark Brown
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox