[alsa-devel] [PATCHv6 5/9] ASOC: wm8971: improve the function of wm8971_set_dai_fmt()

Xavier Hsu xavier.hsu at linaro.org
Mon Dec 1 07:51:57 CET 2014


We use snd_soc_update_bits() to replace snd_soc_write().
"As suggested by Mark Brown"

Signed-off-by: Xavier Hsu <xavier.hsu at linaro.org>
Signed-off-by: Andy Green <andy.green at linaro.org>
---
 sound/soc/codecs/wm8971.c |   18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/sound/soc/codecs/wm8971.c b/sound/soc/codecs/wm8971.c
index b06bd83..5f711bd 100755
--- a/sound/soc/codecs/wm8971.c
+++ b/sound/soc/codecs/wm8971.c
@@ -552,12 +552,11 @@ static int wm8971_set_dai_fmt(struct snd_soc_dai *codec_dai,
 			      unsigned int fmt)
 {
 	struct snd_soc_codec *codec = codec_dai->codec;
-	u16 iface = 0;
 
 	/* set master/slave audio interface */
 	switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
 	case SND_SOC_DAIFMT_CBM_CFM:
-		iface = 0x0040;
+		snd_soc_update_bits(codec, WM8971_IFACE, 0x0040, 0x0040);
 		break;
 	case SND_SOC_DAIFMT_CBS_CFS:
 		break;
@@ -568,18 +567,18 @@ static int wm8971_set_dai_fmt(struct snd_soc_dai *codec_dai,
 	/* interface format */
 	switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
 	case SND_SOC_DAIFMT_I2S:
-		iface |= 0x0002;
+		snd_soc_update_bits(codec, WM8971_IFACE, 0x0002, 0x0002);
 		break;
 	case SND_SOC_DAIFMT_RIGHT_J:
 		break;
 	case SND_SOC_DAIFMT_LEFT_J:
-		iface |= 0x0001;
+		snd_soc_update_bits(codec, WM8971_IFACE, 0x0001, 0x0001);
 		break;
 	case SND_SOC_DAIFMT_DSP_A:
-		iface |= 0x0003;
+		snd_soc_update_bits(codec, WM8971_IFACE, 0x0003, 0x0003);
 		break;
 	case SND_SOC_DAIFMT_DSP_B:
-		iface |= 0x0013;
+		snd_soc_update_bits(codec, WM8971_IFACE, 0x0013, 0x0013);
 		break;
 	default:
 		return -EINVAL;
@@ -590,19 +589,18 @@ static int wm8971_set_dai_fmt(struct snd_soc_dai *codec_dai,
 	case SND_SOC_DAIFMT_NB_NF:
 		break;
 	case SND_SOC_DAIFMT_IB_IF:
-		iface |= 0x0090;
+		snd_soc_update_bits(codec, WM8971_IFACE, 0x0090, 0x0090);
 		break;
 	case SND_SOC_DAIFMT_IB_NF:
-		iface |= 0x0080;
+		snd_soc_update_bits(codec, WM8971_IFACE, 0x0080, 0x0080);
 		break;
 	case SND_SOC_DAIFMT_NB_IF:
-		iface |= 0x0010;
+		snd_soc_update_bits(codec, WM8971_IFACE, 0x0010, 0x0010);
 		break;
 	default:
 		return -EINVAL;
 	}
 
-	snd_soc_write(codec, WM8971_IFACE, iface);
 	return 0;
 }
 
-- 
1.7.9.5



More information about the Alsa-devel mailing list