From: Kuninori Morimoto Date: Tue, 16 Dec 2025 06:24:32 +0000 (+0000) Subject: ASoC: codecs: tas2780: tidyup format check in tas2780_set_fmt() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f764645cb85a8b8f58067289cdfed28f6c1cdf49;p=thirdparty%2Fkernel%2Flinux.git ASoC: codecs: tas2780: tidyup format check in tas2780_set_fmt() Current code is using messy code to check format. Let's cleanup it by using switch(). Signed-off-by: Kuninori Morimoto Link: https://patch.msgid.link/87h5trrljz.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- diff --git a/sound/soc/codecs/tas2780.c b/sound/soc/codecs/tas2780.c index a1963415c9317..cf3f6abd7e7ba 100644 --- a/sound/soc/codecs/tas2780.c +++ b/sound/soc/codecs/tas2780.c @@ -319,25 +319,22 @@ static int tas2780_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) goto err; } - if (((fmt & SND_SOC_DAIFMT_FORMAT_MASK) == SND_SOC_DAIFMT_I2S) - || ((fmt & SND_SOC_DAIFMT_FORMAT_MASK) - == SND_SOC_DAIFMT_DSP_A)){ + switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { + case SND_SOC_DAIFMT_I2S: + case SND_SOC_DAIFMT_DSP_A: iface = TAS2780_TDM_CFG2_SCFG_I2S; tdm_rx_start_slot = 1; - } else { - if (((fmt & SND_SOC_DAIFMT_FORMAT_MASK) - == SND_SOC_DAIFMT_DSP_B) - || ((fmt & SND_SOC_DAIFMT_FORMAT_MASK) - == SND_SOC_DAIFMT_LEFT_J)) { - iface = TAS2780_TDM_CFG2_SCFG_LEFT_J; - tdm_rx_start_slot = 0; - } else { - dev_err(tas2780->dev, - "%s:DAI Format is not found, fmt=0x%x\n", - __func__, fmt); - ret = -EINVAL; - goto err; - } + break; + case SND_SOC_DAIFMT_LEFT_J: + case SND_SOC_DAIFMT_DSP_B: + iface = TAS2780_TDM_CFG2_SCFG_LEFT_J; + tdm_rx_start_slot = 0; + break; + default: + dev_err(tas2780->dev, + "%s:DAI Format is not found, fmt=0x%x\n", __func__, fmt); + ret = -EINVAL; + goto err; } ret = snd_soc_component_update_bits(component, TAS2780_TDM_CFG1, TAS2780_TDM_CFG1_MASK,