diff mbox series

ASoC: rt712-sdca: fix coding style and unconditionally return issues

Message ID 20230210082141.24077-1-shumingf@realtek.com (mailing list archive)
State Accepted
Commit e093e74b819b38074f07289da9933f9c413337ab
Headers show
Series ASoC: rt712-sdca: fix coding style and unconditionally return issues | expand

Commit Message

Shuming [θŒƒζ›ΈιŠ˜] Feb. 10, 2023, 8:21 a.m. UTC
From: Shuming Fan <shumingf@realtek.com>

This patch fixes
1. coding style issues
2. check if the setting was set already in rt712_sdca_mux_put callback

Signed-off-by: Shuming Fan <shumingf@realtek.com>
---
 sound/soc/codecs/rt712-sdca.c | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

Comments

Mark Brown Feb. 10, 2023, 4:50 p.m. UTC | #1
On Fri, 10 Feb 2023 16:21:41 +0800, shumingf@realtek.com wrote:
> This patch fixes
> 1. coding style issues
> 2. check if the setting was set already in rt712_sdca_mux_put callback
> 
> 

Applied to

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

Thanks!

[1/1] ASoC: rt712-sdca: fix coding style and unconditionally return issues
      commit: e093e74b819b38074f07289da9933f9c413337ab

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
diff mbox series

Patch

diff --git a/sound/soc/codecs/rt712-sdca.c b/sound/soc/codecs/rt712-sdca.c
index cc3f6dae1871..8d2fa769bb2e 100644
--- a/sound/soc/codecs/rt712-sdca.c
+++ b/sound/soc/codecs/rt712-sdca.c
@@ -366,8 +366,9 @@  static void rt712_sdca_btn_check_handler(struct work_struct *work)
 				break;
 			}
 		}
-	} else
+	} else {
 		rt712->jack_type = 0;
+	}
 
 	dev_dbg(&rt712->slave->dev, "%s, btn_type=0x%x\n",	__func__, btn_type);
 	snd_soc_jack_report(rt712->hs_jack, rt712->jack_type | btn_type,
@@ -707,6 +708,7 @@  static int rt712_sdca_mux_put(struct snd_kcontrol *kcontrol,
 	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
 	unsigned int *item = ucontrol->value.enumerated.item;
 	unsigned int mask_sft;
+	unsigned int val;
 
 	if (item[0] >= e->items)
 		return -EINVAL;
@@ -718,6 +720,11 @@  static int rt712_sdca_mux_put(struct snd_kcontrol *kcontrol,
 	else
 		return -EINVAL;
 
+	rt712_sdca_index_read(rt712, RT712_VENDOR_HDA_CTL, RT712_MIXER_CTL1, &val);
+	val = (val >> mask_sft) & 0x3;
+	if (!val)
+		return 0;
+
 	rt712_sdca_index_write(rt712, RT712_VENDOR_HDA_CTL,
 		RT712_MIXER_CTL1, 0x3fff);
 	rt712_sdca_index_update_bits(rt712, RT712_VENDOR_HDA_CTL,
@@ -1094,19 +1101,24 @@  static int rt712_sdca_pcm_hw_params(struct snd_pcm_substream *substream,
 	}
 
 	/* set sampling frequency */
-	if (dai->id == RT712_AIF1) {
+	switch (dai->id) {
+	case RT712_AIF1:
 		regmap_write(rt712->regmap,
 			SDW_SDCA_CTL(FUNC_NUM_JACK_CODEC, RT712_SDCA_ENT_CS01, RT712_SDCA_CTL_SAMPLE_FREQ_INDEX, 0),
 			sampling_rate);
 		regmap_write(rt712->regmap,
 			SDW_SDCA_CTL(FUNC_NUM_JACK_CODEC, RT712_SDCA_ENT_CS11, RT712_SDCA_CTL_SAMPLE_FREQ_INDEX, 0),
 			sampling_rate);
-	}
-
-	if (dai->id == RT712_AIF2)
+		break;
+	case RT712_AIF2:
 		regmap_write(rt712->regmap,
 			SDW_SDCA_CTL(FUNC_NUM_AMP, RT712_SDCA_ENT_CS31, RT712_SDCA_CTL_SAMPLE_FREQ_INDEX, 0),
 			sampling_rate);
+		break;
+	default:
+		dev_err(component->dev, "Wrong DAI id\n");
+		return -EINVAL;
+	}
 
 	return 0;
 }