public inbox for alsa-devel@alsa-project.org
 help / color / mirror / Atom feed
From: "Andrew F. Davis" <afd@ti.com>
To: Liam Girdwood <lgirdwood@gmail.com>, Mark Brown <broonie@kernel.org>
Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org,
	"Andrew F . Davis" <afd@ti.com>
Subject: [PATCH 09/10] ASoC: tlv320aic32x4: Use snd_soc_update_bits() in aic32x4_set_dai_fmt()
Date: Tue, 12 Dec 2017 16:43:10 -0600	[thread overview]
Message-ID: <20171212224311.24045-9-afd@ti.com> (raw)
In-Reply-To: <20171212224311.24045-1-afd@ti.com>

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>
---
 sound/soc/codecs/tlv320aic32x4.c | 28 +++++++++++++---------------
 1 file changed, 13 insertions(+), 15 deletions(-)

diff --git a/sound/soc/codecs/tlv320aic32x4.c b/sound/soc/codecs/tlv320aic32x4.c
index 7a570afac8df..cccb3c2edb64 100644
--- a/sound/soc/codecs/tlv320aic32x4.c
+++ b/sound/soc/codecs/tlv320aic32x4.c
@@ -598,16 +598,9 @@ static int aic32x4_set_dai_sysclk(struct snd_soc_dai *codec_dai,
 static int aic32x4_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
 {
 	struct snd_soc_codec *codec = codec_dai->codec;
-	u8 iface_reg_1;
-	u8 iface_reg_2;
-	u8 iface_reg_3;
-
-	iface_reg_1 = snd_soc_read(codec, AIC32X4_IFACE1);
-	iface_reg_1 = iface_reg_1 & ~(3 << 6 | 3 << 2);
-	iface_reg_2 = snd_soc_read(codec, AIC32X4_IFACE2);
-	iface_reg_2 = 0;
-	iface_reg_3 = snd_soc_read(codec, AIC32X4_IFACE3);
-	iface_reg_3 = iface_reg_3 & ~(1 << 3);
+	u8 iface_reg_1 = 0;
+	u8 iface_reg_2 = 0;
+	u8 iface_reg_3 = 0;
 
 	/* set master/slave audio interface */
 	switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
@@ -627,13 +620,13 @@ static int aic32x4_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
 	case SND_SOC_DAIFMT_DSP_A:
 		iface_reg_1 |= (AIC32X4_DSP_MODE <<
 				AIC32X4_IFACE1_DATATYPE_SHIFT);
-		iface_reg_3 |= (1 << 3); /* invert bit clock */
+		iface_reg_3 |= AIC32X4_BCLKINV_MASK; /* invert bit clock */
 		iface_reg_2 = 0x01; /* add offset 1 */
 		break;
 	case SND_SOC_DAIFMT_DSP_B:
 		iface_reg_1 |= (AIC32X4_DSP_MODE <<
 				AIC32X4_IFACE1_DATATYPE_SHIFT);
-		iface_reg_3 |= (1 << 3); /* invert bit clock */
+		iface_reg_3 |= AIC32X4_BCLKINV_MASK; /* invert bit clock */
 		break;
 	case SND_SOC_DAIFMT_RIGHT_J:
 		iface_reg_1 |= (AIC32X4_RIGHT_JUSTIFIED_MODE <<
@@ -648,9 +641,14 @@ static int aic32x4_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
 		return -EINVAL;
 	}
 
-	snd_soc_write(codec, AIC32X4_IFACE1, iface_reg_1);
-	snd_soc_write(codec, AIC32X4_IFACE2, iface_reg_2);
-	snd_soc_write(codec, AIC32X4_IFACE3, iface_reg_3);
+	snd_soc_update_bits(codec, AIC32X4_IFACE1,
+			    AIC32X4_IFACE1_DATATYPE_MASK |
+			    AIC32X4_IFACE1_MASTER_MASK, iface_reg_1);
+	snd_soc_update_bits(codec, AIC32X4_IFACE2,
+			    AIC32X4_DATA_OFFSET_MASK, iface_reg_2);
+	snd_soc_update_bits(codec, AIC32X4_IFACE3,
+			    AIC32X4_BCLKINV_MASK, iface_reg_3);
+
 	return 0;
 }
 
-- 
2.15.0

  parent reply	other threads:[~2017-12-12 22:43 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-12 22:43 [PATCH 01/10] ASoC: tlv320aic32x4: Remove filename from header and switch to SPDX Andrew F. Davis
2017-12-12 22:43 ` [PATCH 02/10] ASoC: tlv320aic32x4: Use AIC32X4_REG macro for all register definitions Andrew F. Davis
2017-12-13 15:46   ` Applied "ASoC: tlv320aic32x4: Use AIC32X4_REG macro for all register definitions" to the asoc tree Mark Brown
2017-12-12 22:43 ` [PATCH 03/10] ASoC: tlv320aic32x4: Drop define mapping from number to number Andrew F. Davis
2017-12-13 15:45   ` Applied "ASoC: tlv320aic32x4: Drop define mapping from number to number" to the asoc tree Mark Brown
2017-12-12 22:43 ` [PATCH 04/10] ASoC: tlv320aic32x4: Use correct shift definition for DATATYPE bits Andrew F. Davis
2017-12-13 15:45   ` Applied "ASoC: tlv320aic32x4: Use correct shift definition for DATATYPE bits" to the asoc tree Mark Brown
2017-12-12 22:43 ` [PATCH 05/10] ASoC: tlv320aic32x4: Use correct shift definition for DATALEN bits Andrew F. Davis
2017-12-13 15:45   ` Applied "ASoC: tlv320aic32x4: Use correct shift definition for DATALEN bits" to the asoc tree Mark Brown
2017-12-12 22:43 ` [PATCH 06/10] ASoC: tlv320aic32x4: Use BIT and GENMASK for bit field definitions Andrew F. Davis
2017-12-13 15:45   ` Applied "ASoC: tlv320aic32x4: Use BIT and GENMASK for bit field definitions" to the asoc tree Mark Brown
2017-12-12 22:43 ` [PATCH 07/10] ASoC: tlv320aic32x4: Use snd_soc_update_bits() in aic32x4_mute() Andrew F. Davis
2017-12-13 15:45   ` Applied "ASoC: tlv320aic32x4: Use snd_soc_update_bits() in aic32x4_mute()" to the asoc tree Mark Brown
2017-12-12 22:43 ` [PATCH 08/10] ASoC: tlv320aic32x4: Use snd_soc_update_bits() in aic32x4_hw_params() Andrew F. Davis
2017-12-13 15:45   ` Applied "ASoC: tlv320aic32x4: Use snd_soc_update_bits() in aic32x4_hw_params()" to the asoc tree Mark Brown
2017-12-12 22:43 ` Andrew F. Davis [this message]
2017-12-13 15:44   ` Applied "ASoC: tlv320aic32x4: Use snd_soc_update_bits() in aic32x4_set_dai_fmt()" " Mark Brown
2017-12-12 22:43 ` [PATCH 10/10] ASoC: tlv320aic32x4: Make driver selectable in Kconfig Andrew F. Davis
2017-12-13 15:44   ` Applied "ASoC: tlv320aic32x4: Make driver selectable in Kconfig" to the asoc tree Mark Brown
2017-12-13  2:19 ` [PATCH 01/10] ASoC: tlv320aic32x4: Remove filename from header and switch to SPDX Joe Perches
2017-12-13 15:44   ` Andrew F. Davis
2017-12-13 15:50     ` Joe Perches
2017-12-13 15:51       ` Andrew F. Davis
2017-12-13 15:50     ` Andrew F. Davis
2017-12-13 16:01       ` Mark Brown
2017-12-13 12:28 ` Mark Brown
2017-12-13 16:13   ` Andrew F. Davis
2017-12-13 17:00     ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171212224311.24045-9-afd@ti.com \
    --to=afd@ti.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox