Skip to contentSkip to conversation

ASoC: cs35l32: Simplify implementation of cs35l32_codec_set_sysclk

PATCH Applied Axel Lin 3 participants 3 messages Aug 28, 2014

Subsystems (3)
lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 ASoC: cs35l32: Simplify implementation of cs35l32_codec_set_sysclk

Use single snd_soc_update_bits() call to update the register bits.

---
 sound/soc/codecs/cs35l32.c | 28 +++++++---------------------
 1 file changed, 7 insertions(+), 21 deletions(-)
sound/soc/codecs/cs35l32.c +7 -21
index 9c6b272..380c212 100644
@@ -242,41 +242,27 @@ static struct snd_soc_dai_driver cs35l32_dai[] = {
 static int cs35l32_codec_set_sysclk(struct snd_soc_codec *codec,
 			      int clk_id, int source, unsigned int freq, int dir)
 {
+	unsigned int val;
 
 	switch (freq) {
 	case 6000000:
-		snd_soc_update_bits(codec, CS35L32_CLK_CTL,
-				    CS35L32_MCLK_DIV2_MASK, 0);
-		snd_soc_update_bits(codec, CS35L32_CLK_CTL,
-				    CS35L32_MCLK_RATIO_MASK,
-					CS35L32_MCLK_RATIO);
+		val = CS35L32_MCLK_RATIO;
 		break;
 	case 12000000:
-		snd_soc_update_bits(codec, CS35L32_CLK_CTL,
-				    CS35L32_MCLK_DIV2_MASK,
-					CS35L32_MCLK_DIV2_MASK);
-		snd_soc_update_bits(codec, CS35L32_CLK_CTL,
-				    CS35L32_MCLK_RATIO_MASK,
-					CS35L32_MCLK_RATIO);
+		val = CS35L32_MCLK_DIV2_MASK | CS35L32_MCLK_RATIO;
 		break;
 	case 6144000:
-		snd_soc_update_bits(codec, CS35L32_CLK_CTL,
-				    CS35L32_MCLK_DIV2_MASK, 0);
-		snd_soc_update_bits(codec, CS35L32_CLK_CTL,
-				    CS35L32_MCLK_RATIO_MASK, 0);
+		val = 0;
 		break;
 	case 12288000:
-		snd_soc_update_bits(codec, CS35L32_CLK_CTL,
-				    CS35L32_MCLK_DIV2_MASK,
-					CS35L32_MCLK_DIV2_MASK);
-		snd_soc_update_bits(codec, CS35L32_CLK_CTL,
-				    CS35L32_MCLK_RATIO_MASK, 0);
+		val = CS35L32_MCLK_DIV2_MASK;
 		break;
 	default:
 		return -EINVAL;
 	}
 
-	return 0;
+	return snd_soc_update_bits(codec, CS35L32_CLK_CTL,
+			CS35L32_MCLK_DIV2_MASK | CS35L32_MCLK_RATIO_MASK, val);
 }
 
 static struct snd_soc_codec_driver soc_codec_dev_cs35l32 = {
Signature · 1 line
1.9.1
Tested-by Acked-by on v1 1/1
#1 lore raw

sound/soc/codecs/cs35l32.c

Quoted 11 lines · Axel Lin

Use single snd_soc_update_bits() call to update the register bits.

---
 sound/soc/codecs/cs35l32.c | 28 +++++++---------------------
 1 file changed, 7 insertions(+), 21 deletions(-)
sound/soc/codecs/cs35l32.c +0 -0
index 9c6b272..380c212 100644

Thanks Axel,