]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
ASoC: wm8741: Use snd_soc_update_bits rather than hard coding
authorCharles Keepax <ckeepax@opensource.cirrus.com>
Wed, 1 Nov 2017 11:03:25 +0000 (11:03 +0000)
committerMark Brown <broonie@kernel.org>
Wed, 1 Nov 2017 13:59:44 +0000 (13:59 +0000)
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/wm8741.c

index b8c1940f2243de45ea64edcfbbac01f40ca80e3e..3c96af057a3e3390b22dcd4e36948e773db7913f 100644 (file)
@@ -196,7 +196,7 @@ static int wm8741_hw_params(struct snd_pcm_substream *substream,
 {
        struct snd_soc_codec *codec = dai->codec;
        struct wm8741_priv *wm8741 = snd_soc_codec_get_drvdata(codec);
-       u16 iface = snd_soc_read(codec, WM8741_FORMAT_CONTROL) & 0x1FC;
+       unsigned int iface;
        int i;
 
        /* The set of sample rates that can be supported depends on the
@@ -223,15 +223,16 @@ static int wm8741_hw_params(struct snd_pcm_substream *substream,
        /* bit size */
        switch (params_width(params)) {
        case 16:
+               iface = 0x0;
                break;
        case 20:
-               iface |= 0x0001;
+               iface = 0x1;
                break;
        case 24:
-               iface |= 0x0002;
+               iface = 0x2;
                break;
        case 32:
-               iface |= 0x0003;
+               iface = 0x3;
                break;
        default:
                dev_dbg(codec->dev, "wm8741_hw_params:    Unsupported bit size param = %d",
@@ -242,7 +243,9 @@ static int wm8741_hw_params(struct snd_pcm_substream *substream,
        dev_dbg(codec->dev, "wm8741_hw_params:    bit size param = %d, rate param = %d",
                params_width(params), params_rate(params));
 
-       snd_soc_write(codec, WM8741_FORMAT_CONTROL, iface);
+       snd_soc_update_bits(codec, WM8741_FORMAT_CONTROL, WM8741_IWL_MASK,
+                           iface);
+
        return 0;
 }
 
@@ -295,7 +298,7 @@ static int wm8741_set_dai_fmt(struct snd_soc_dai *codec_dai,
                unsigned int fmt)
 {
        struct snd_soc_codec *codec = codec_dai->codec;
-       u16 iface = snd_soc_read(codec, WM8741_FORMAT_CONTROL) & 0x1C3;
+       unsigned int iface;
 
        /* check master/slave audio interface */
        switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
@@ -308,18 +311,19 @@ static int wm8741_set_dai_fmt(struct snd_soc_dai *codec_dai,
        /* interface format */
        switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
        case SND_SOC_DAIFMT_I2S:
-               iface |= 0x0008;
+               iface = 0x08;
                break;
        case SND_SOC_DAIFMT_RIGHT_J:
+               iface = 0x00;
                break;
        case SND_SOC_DAIFMT_LEFT_J:
-               iface |= 0x0004;
+               iface = 0x04;
                break;
        case SND_SOC_DAIFMT_DSP_A:
-               iface |= 0x000C;
+               iface = 0x0C;
                break;
        case SND_SOC_DAIFMT_DSP_B:
-               iface |= 0x001C;
+               iface = 0x1C;
                break;
        default:
                return -EINVAL;
@@ -330,13 +334,13 @@ static int wm8741_set_dai_fmt(struct snd_soc_dai *codec_dai,
        case SND_SOC_DAIFMT_NB_NF:
                break;
        case SND_SOC_DAIFMT_IB_IF:
-               iface |= 0x0010;
+               iface |= 0x10;
                break;
        case SND_SOC_DAIFMT_IB_NF:
-               iface |= 0x0020;
+               iface |= 0x20;
                break;
        case SND_SOC_DAIFMT_NB_IF:
-               iface |= 0x0030;
+               iface |= 0x30;
                break;
        default:
                return -EINVAL;
@@ -347,7 +351,10 @@ static int wm8741_set_dai_fmt(struct snd_soc_dai *codec_dai,
                                fmt & SND_SOC_DAIFMT_FORMAT_MASK,
                                ((fmt & SND_SOC_DAIFMT_INV_MASK)));
 
-       snd_soc_write(codec, WM8741_FORMAT_CONTROL, iface);
+       snd_soc_update_bits(codec, WM8741_FORMAT_CONTROL,
+                           WM8741_BCP_MASK | WM8741_LRP_MASK | WM8741_FMT_MASK,
+                           iface);
+
        return 0;
 }