mirror of
https://github.com/torvalds/linux.git
synced 2026-03-08 05:04:51 +01:00
ASoC: es8328: Check errors in set_dai_fmt()
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> Link: https://patch.msgid.link/20260130160017.2630-4-hungen3108@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
0801a03a31
commit
3570e8eef2
1 changed files with 21 additions and 9 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue