Skip to content

Commit

Permalink
ASoC: cs35l32: Simplify implementation of cs35l32_codec_set_sysclk
Browse files Browse the repository at this point in the history
Use single snd_soc_update_bits() call to update the register bits.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Tested-by: Brian Austin <brian.austin@cirrus.com>
Acked-by: Brian Austin <brian.austin@cirrus.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
  • Loading branch information
Axel Lin authored and Mark Brown committed Aug 28, 2014
1 parent 1a83269 commit 5f609f2
Showing 1 changed file with 7 additions and 21 deletions.
28 changes: 7 additions & 21 deletions sound/soc/codecs/cs35l32.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down

0 comments on commit 5f609f2

Please sign in to comment.