[PATCH v3 2/6] ASoC: dwc: Fix error handling in dw_i2s_set_fmt()
From: phucduc . bui
Date: Tue Nov 10 2026 - 21:29:43 EST
From: bui duc phuc <phucduc.bui@xxxxxxxxx>
Return early when an unsupported clock provider format is
encountered, preventing the function from updating frame_offset
before returning an error.
Fixes: 221acc16aee1 ("ASoC: dwc: Add TDM mode support")
Reviewed-by: Maxim Kochetkov <fido_max@xxxxxxxx>
Signed-off-by: bui duc phuc <phucduc.bui@xxxxxxxxx>
---
Changes in v2:
- Move the typo fixes into a separate commit.
- Add Maxim Kochetkov's Reviewed-by tag.
sound/soc/dwc/dwc-i2s.c | 22 ++++++----------------
1 file changed, 6 insertions(+), 16 deletions(-)
diff --git a/sound/soc/dwc/dwc-i2s.c b/sound/soc/dwc/dwc-i2s.c
index 1f4d06a82333..6a25d2a69ea7 100644
--- a/sound/soc/dwc/dwc-i2s.c
+++ b/sound/soc/dwc/dwc-i2s.c
@@ -390,29 +390,19 @@ static int dw_i2s_trigger(struct snd_pcm_substream *substream,
static int dw_i2s_set_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt)
{
struct dw_i2s_dev *dev = snd_soc_dai_get_drvdata(cpu_dai);
- int ret = 0;
switch (fmt & SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK) {
case SND_SOC_DAIFMT_BC_FC:
- if (dev->capability & DW_I2S_SLAVE)
- ret = 0;
- else
- ret = -EINVAL;
+ if (!(dev->capability & DW_I2S_SLAVE))
+ return -EINVAL;
break;
case SND_SOC_DAIFMT_BP_FP:
- if (dev->capability & DW_I2S_MASTER)
- ret = 0;
- else
- ret = -EINVAL;
- break;
- case SND_SOC_DAIFMT_BC_FP:
- case SND_SOC_DAIFMT_BP_FC:
- ret = -EINVAL;
+ if (!(dev->capability & DW_I2S_MASTER))
+ return -EINVAL;
break;
default:
dev_dbg(dev->dev, "dwc : Invalid clock provider format\n");
- ret = -EINVAL;
- break;
+ return -EINVAL;
}
switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
@@ -431,7 +421,7 @@ static int dw_i2s_set_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt)
return -EINVAL;
}
- return ret;
+ return 0;
}
static int dw_i2s_set_tdm_slot(struct snd_soc_dai *cpu_dai, unsigned int tx_mask,
--
2.43.0