diff options
| author | Andrew F. Davis <afd@ti.com> | 2017-12-12 17:43:10 -0500 |
|---|---|---|
| committer | Mark Brown <broonie@kernel.org> | 2017-12-13 07:29:14 -0500 |
| commit | 60fb4be565c9c44f6999aaa9d18808f1ac49d6ef (patch) | |
| tree | 96025a7357a5fabcd3d18b08c9a34b4af3c45811 | |
| parent | 64aab89974ebddf4cc67e4ed8996d879a9d054b9 (diff) | |
ASoC: tlv320aic32x4: Use snd_soc_update_bits() in aic32x4_set_dai_fmt()
Make the code easier to read by using snd_soc_update_bits() over
read/modify/write sequences.
Signed-off-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
| -rw-r--r-- | sound/soc/codecs/tlv320aic32x4.c | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/sound/soc/codecs/tlv320aic32x4.c b/sound/soc/codecs/tlv320aic32x4.c index 63a52cdb7afe..fea019343c3b 100644 --- a/sound/soc/codecs/tlv320aic32x4.c +++ b/sound/soc/codecs/tlv320aic32x4.c | |||
| @@ -614,16 +614,9 @@ static int aic32x4_set_dai_sysclk(struct snd_soc_dai *codec_dai, | |||
| 614 | static int aic32x4_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) | 614 | static int aic32x4_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) |
| 615 | { | 615 | { |
| 616 | struct snd_soc_codec *codec = codec_dai->codec; | 616 | struct snd_soc_codec *codec = codec_dai->codec; |
| 617 | u8 iface_reg_1; | 617 | u8 iface_reg_1 = 0; |
| 618 | u8 iface_reg_2; | 618 | u8 iface_reg_2 = 0; |
| 619 | u8 iface_reg_3; | 619 | u8 iface_reg_3 = 0; |
| 620 | |||
| 621 | iface_reg_1 = snd_soc_read(codec, AIC32X4_IFACE1); | ||
| 622 | iface_reg_1 = iface_reg_1 & ~(3 << 6 | 3 << 2); | ||
| 623 | iface_reg_2 = snd_soc_read(codec, AIC32X4_IFACE2); | ||
| 624 | iface_reg_2 = 0; | ||
| 625 | iface_reg_3 = snd_soc_read(codec, AIC32X4_IFACE3); | ||
| 626 | iface_reg_3 = iface_reg_3 & ~(1 << 3); | ||
| 627 | 620 | ||
| 628 | /* set master/slave audio interface */ | 621 | /* set master/slave audio interface */ |
| 629 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { | 622 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { |
| @@ -643,13 +636,13 @@ static int aic32x4_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) | |||
| 643 | case SND_SOC_DAIFMT_DSP_A: | 636 | case SND_SOC_DAIFMT_DSP_A: |
| 644 | iface_reg_1 |= (AIC32X4_DSP_MODE << | 637 | iface_reg_1 |= (AIC32X4_DSP_MODE << |
| 645 | AIC32X4_IFACE1_DATATYPE_SHIFT); | 638 | AIC32X4_IFACE1_DATATYPE_SHIFT); |
| 646 | iface_reg_3 |= (1 << 3); /* invert bit clock */ | 639 | iface_reg_3 |= AIC32X4_BCLKINV_MASK; /* invert bit clock */ |
| 647 | iface_reg_2 = 0x01; /* add offset 1 */ | 640 | iface_reg_2 = 0x01; /* add offset 1 */ |
| 648 | break; | 641 | break; |
| 649 | case SND_SOC_DAIFMT_DSP_B: | 642 | case SND_SOC_DAIFMT_DSP_B: |
| 650 | iface_reg_1 |= (AIC32X4_DSP_MODE << | 643 | iface_reg_1 |= (AIC32X4_DSP_MODE << |
| 651 | AIC32X4_IFACE1_DATATYPE_SHIFT); | 644 | AIC32X4_IFACE1_DATATYPE_SHIFT); |
| 652 | iface_reg_3 |= (1 << 3); /* invert bit clock */ | 645 | iface_reg_3 |= AIC32X4_BCLKINV_MASK; /* invert bit clock */ |
| 653 | break; | 646 | break; |
| 654 | case SND_SOC_DAIFMT_RIGHT_J: | 647 | case SND_SOC_DAIFMT_RIGHT_J: |
| 655 | iface_reg_1 |= (AIC32X4_RIGHT_JUSTIFIED_MODE << | 648 | iface_reg_1 |= (AIC32X4_RIGHT_JUSTIFIED_MODE << |
| @@ -664,9 +657,14 @@ static int aic32x4_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) | |||
| 664 | return -EINVAL; | 657 | return -EINVAL; |
| 665 | } | 658 | } |
| 666 | 659 | ||
| 667 | snd_soc_write(codec, AIC32X4_IFACE1, iface_reg_1); | 660 | snd_soc_update_bits(codec, AIC32X4_IFACE1, |
| 668 | snd_soc_write(codec, AIC32X4_IFACE2, iface_reg_2); | 661 | AIC32X4_IFACE1_DATATYPE_MASK | |
| 669 | snd_soc_write(codec, AIC32X4_IFACE3, iface_reg_3); | 662 | AIC32X4_IFACE1_MASTER_MASK, iface_reg_1); |
| 663 | snd_soc_update_bits(codec, AIC32X4_IFACE2, | ||
| 664 | AIC32X4_DATA_OFFSET_MASK, iface_reg_2); | ||
| 665 | snd_soc_update_bits(codec, AIC32X4_IFACE3, | ||
| 666 | AIC32X4_BCLKINV_MASK, iface_reg_3); | ||
| 667 | |||
| 670 | return 0; | 668 | return 0; |
| 671 | } | 669 | } |
| 672 | 670 | ||
