ASoC: Avoid direct register cache access when setting defaults
authorMark Brown <broonie@opensource.wolfsonmicro.com>
Fri, 24 Dec 2010 16:59:30 +0000 (16:59 +0000)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Mon, 17 Jan 2011 13:59:39 +0000 (13:59 +0000)
Directly accessing the register cache means that we can't use anything
except a flat register cache so use snd_soc_update_bits().

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
sound/soc/codecs/wm8523.c
sound/soc/codecs/wm8741.c
sound/soc/codecs/wm8904.c
sound/soc/codecs/wm8955.c
sound/soc/codecs/wm8962.c
sound/soc/codecs/wm8978.c
sound/soc/codecs/wm9090.c

index 83e86f077ee168bcd16e78d7cede797a01b5c15f..4fd4d8dca0fc0af31439371fbab9040794162095 100644 (file)
@@ -414,7 +414,6 @@ static int wm8523_resume(struct snd_soc_codec *codec)
 static int wm8523_probe(struct snd_soc_codec *codec)
 {
        struct wm8523_priv *wm8523 = snd_soc_codec_get_drvdata(codec);
-       u16 *reg_cache = codec->reg_cache;
        int ret, i;
 
        codec->hw_write = (hw_write_t)i2c_master_send;
@@ -471,8 +470,9 @@ static int wm8523_probe(struct snd_soc_codec *codec)
        }
 
        /* Change some default settings - latch VU and enable ZC */
-       reg_cache[WM8523_DAC_GAINR] |= WM8523_DACR_VU;
-       reg_cache[WM8523_DAC_CTRL3] |= WM8523_ZC;
+       snd_soc_update_bits(codec, WM8523_DAC_GAINR,
+                           WM8523_DACR_VU, WM8523_DACR_VU);
+       snd_soc_update_bits(codec, WM8523_DAC_CTRL3, WM8523_ZC, WM8523_ZC);
 
        wm8523_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
 
index 494f2d31d75bc7836a550c517580cc2de69ec56d..25af901fe8133029e7efe35914c07e02105e4085 100644 (file)
@@ -421,7 +421,6 @@ static int wm8741_resume(struct snd_soc_codec *codec)
 static int wm8741_probe(struct snd_soc_codec *codec)
 {
        struct wm8741_priv *wm8741 = snd_soc_codec_get_drvdata(codec);
-       u16 *reg_cache = codec->reg_cache;
        int ret = 0;
 
        ret = snd_soc_codec_set_cache_io(codec, 7, 9, wm8741->control_type);
@@ -437,10 +436,14 @@ static int wm8741_probe(struct snd_soc_codec *codec)
        }
 
        /* Change some default settings - latch VU */
-       reg_cache[WM8741_DACLLSB_ATTENUATION] |= WM8741_UPDATELL;
-       reg_cache[WM8741_DACLMSB_ATTENUATION] |= WM8741_UPDATELM;
-       reg_cache[WM8741_DACRLSB_ATTENUATION] |= WM8741_UPDATERL;
-       reg_cache[WM8741_DACRLSB_ATTENUATION] |= WM8741_UPDATERM;
+       snd_soc_update_bits(codec, WM8741_DACLLSB_ATTENUATION,
+                           WM8741_UPDATELL, WM8741_UPDATELL);
+       snd_soc_update_bits(codec, WM8741_DACLMSB_ATTENUATION,
+                           WM8741_UPDATELM, WM8741_UPDATELM);
+       snd_soc_update_bits(codec, WM8741_DACRLSB_ATTENUATION,
+                           WM8741_UPDATERL, WM8741_UPDATERL);
+       snd_soc_update_bits(codec, WM8741_DACRLSB_ATTENUATION,
+                           WM8741_UPDATERM, WM8741_UPDATERM);
 
        snd_soc_add_controls(codec, wm8741_snd_controls,
                             ARRAY_SIZE(wm8741_snd_controls));
index 17a8fe9b39b925a9f04fbefab1c02a93f70f08a5..443ae580445cb7f207029a5711eba52a5e49f157 100644 (file)
@@ -2436,19 +2436,28 @@ static int wm8904_probe(struct snd_soc_codec *codec)
        }
 
        /* Change some default settings - latch VU and enable ZC */
-       reg_cache[WM8904_ADC_DIGITAL_VOLUME_LEFT] |= WM8904_ADC_VU;
-       reg_cache[WM8904_ADC_DIGITAL_VOLUME_RIGHT] |= WM8904_ADC_VU;
-       reg_cache[WM8904_DAC_DIGITAL_VOLUME_LEFT] |= WM8904_DAC_VU;
-       reg_cache[WM8904_DAC_DIGITAL_VOLUME_RIGHT] |= WM8904_DAC_VU;
-       reg_cache[WM8904_ANALOGUE_OUT1_LEFT] |= WM8904_HPOUT_VU |
-               WM8904_HPOUTLZC;
-       reg_cache[WM8904_ANALOGUE_OUT1_RIGHT] |= WM8904_HPOUT_VU |
-               WM8904_HPOUTRZC;
-       reg_cache[WM8904_ANALOGUE_OUT2_LEFT] |= WM8904_LINEOUT_VU |
-               WM8904_LINEOUTLZC;
-       reg_cache[WM8904_ANALOGUE_OUT2_RIGHT] |= WM8904_LINEOUT_VU |
-               WM8904_LINEOUTRZC;
-       reg_cache[WM8904_CLOCK_RATES_0] &= ~WM8904_SR_MODE;
+       snd_soc_update_bits(codec, WM8904_ADC_DIGITAL_VOLUME_LEFT,
+                           WM8904_ADC_VU, WM8904_ADC_VU);
+       snd_soc_update_bits(codec, WM8904_ADC_DIGITAL_VOLUME_RIGHT,
+                           WM8904_ADC_VU, WM8904_ADC_VU);
+       snd_soc_update_bits(codec, WM8904_DAC_DIGITAL_VOLUME_LEFT,
+                           WM8904_DAC_VU, WM8904_DAC_VU);
+       snd_soc_update_bits(codec, WM8904_DAC_DIGITAL_VOLUME_RIGHT,
+                           WM8904_DAC_VU, WM8904_DAC_VU);
+       snd_soc_update_bits(codec, WM8904_ANALOGUE_OUT1_LEFT,
+                           WM8904_HPOUT_VU | WM8904_HPOUTLZC,
+                           WM8904_HPOUT_VU | WM8904_HPOUTLZC);
+       snd_soc_update_bits(codec, WM8904_ANALOGUE_OUT1_RIGHT,
+                           WM8904_HPOUT_VU | WM8904_HPOUTRZC,
+                           WM8904_HPOUT_VU | WM8904_HPOUTRZC);
+       snd_soc_update_bits(codec, WM8904_ANALOGUE_OUT2_LEFT,
+                           WM8904_LINEOUT_VU | WM8904_LINEOUTLZC,
+                           WM8904_LINEOUT_VU | WM8904_LINEOUTLZC);
+       snd_soc_update_bits(codec, WM8904_ANALOGUE_OUT2_RIGHT,
+                           WM8904_LINEOUT_VU | WM8904_LINEOUTRZC,
+                           WM8904_LINEOUT_VU | WM8904_LINEOUTRZC);
+       snd_soc_update_bits(codec, WM8904_CLOCK_RATES_0,
+                           WM8904_SR_MODE, 0);
 
        /* Apply configuration from the platform data. */
        if (wm8904->pdata) {
@@ -2469,10 +2478,12 @@ static int wm8904_probe(struct snd_soc_codec *codec)
        /* Set Class W by default - this will be managed by the Class
         * G widget at runtime where bypass paths are available.
         */
-       reg_cache[WM8904_CLASS_W_0] |= WM8904_CP_DYN_PWR;
+       snd_soc_update_bits(codec, WM8904_CLASS_W_0,
+                           WM8904_CP_DYN_PWR, WM8904_CP_DYN_PWR);
 
        /* Use normal bias source */
-       reg_cache[WM8904_BIAS_CONTROL_0] &= ~WM8904_POBCTRL;
+       snd_soc_update_bits(codec, WM8904_BIAS_CONTROL_0,
+                           WM8904_POBCTRL, 0);
 
        wm8904_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
 
index 7167dfc96aa7558c7c36d8a8983eb9c9ee5df846..5e0214d6293ea57672ebc54c427470e50768e4ca 100644 (file)
@@ -934,16 +934,27 @@ static int wm8955_probe(struct snd_soc_codec *codec)
        }
 
        /* Change some default settings - latch VU and enable ZC */
-       reg_cache[WM8955_LEFT_DAC_VOLUME] |= WM8955_LDVU;
-       reg_cache[WM8955_RIGHT_DAC_VOLUME] |= WM8955_RDVU;
-       reg_cache[WM8955_LOUT1_VOLUME] |= WM8955_LO1VU | WM8955_LO1ZC;
-       reg_cache[WM8955_ROUT1_VOLUME] |= WM8955_RO1VU | WM8955_RO1ZC;
-       reg_cache[WM8955_LOUT2_VOLUME] |= WM8955_LO2VU | WM8955_LO2ZC;
-       reg_cache[WM8955_ROUT2_VOLUME] |= WM8955_RO2VU | WM8955_RO2ZC;
-       reg_cache[WM8955_MONOOUT_VOLUME] |= WM8955_MOZC;
+       snd_soc_update_bits(codec, WM8955_LEFT_DAC_VOLUME,
+                           WM8955_LDVU, WM8955_LDVU);
+       snd_soc_update_bits(codec, WM8955_RIGHT_DAC_VOLUME,
+                           WM8955_RDVU, WM8955_RDVU);
+       snd_soc_update_bits(codec, WM8955_LOUT1_VOLUME,
+                           WM8955_LO1VU | WM8955_LO1ZC,
+                           WM8955_LO1VU | WM8955_LO1ZC);
+       snd_soc_update_bits(codec, WM8955_ROUT1_VOLUME,
+                           WM8955_RO1VU | WM8955_RO1ZC,
+                           WM8955_RO1VU | WM8955_RO1ZC);
+       snd_soc_update_bits(codec, WM8955_LOUT2_VOLUME,
+                           WM8955_LO2VU | WM8955_LO2ZC,
+                           WM8955_LO2VU | WM8955_LO2ZC);
+       snd_soc_update_bits(codec, WM8955_ROUT2_VOLUME,
+                           WM8955_RO2VU | WM8955_RO2ZC,
+                           WM8955_RO2VU | WM8955_RO2ZC);
+       snd_soc_update_bits(codec, WM8955_MONOOUT_VOLUME,
+                           WM8955_MOZC, WM8955_MOZC);
 
        /* Also enable adaptive bass boost by default */
-       reg_cache[WM8955_BASS_CONTROL] |= WM8955_BB;
+       snd_soc_update_bits(codec, WM8955_BASS_CONTROL, WM8955_BB, WM8955_BB);
 
        /* Set platform data values */
        if (pdata) {
index 7c02924beddf16c0ac0c9dfa27c06e39a9035b00..5c7b730a864fbaeb8f0c5fc65ba1ff3e971e8c58 100644 (file)
@@ -3822,16 +3822,26 @@ static int wm8962_probe(struct snd_soc_codec *codec)
        }
 
        /* Latch volume update bits */
-       reg_cache[WM8962_LEFT_INPUT_VOLUME] |= WM8962_IN_VU;
-       reg_cache[WM8962_RIGHT_INPUT_VOLUME] |= WM8962_IN_VU;
-       reg_cache[WM8962_LEFT_ADC_VOLUME] |= WM8962_ADC_VU;
-       reg_cache[WM8962_RIGHT_ADC_VOLUME] |= WM8962_ADC_VU;
-       reg_cache[WM8962_LEFT_DAC_VOLUME] |= WM8962_DAC_VU;
-       reg_cache[WM8962_RIGHT_DAC_VOLUME] |= WM8962_DAC_VU;
-       reg_cache[WM8962_SPKOUTL_VOLUME] |= WM8962_SPKOUT_VU;
-       reg_cache[WM8962_SPKOUTR_VOLUME] |= WM8962_SPKOUT_VU;
-       reg_cache[WM8962_HPOUTL_VOLUME] |= WM8962_HPOUT_VU;
-       reg_cache[WM8962_HPOUTR_VOLUME] |= WM8962_HPOUT_VU;
+       snd_soc_update_bits(codec, WM8962_LEFT_INPUT_VOLUME,
+                           WM8962_IN_VU, WM8962_IN_VU);
+       snd_soc_update_bits(codec, WM8962_RIGHT_INPUT_VOLUME,
+                           WM8962_IN_VU, WM8962_IN_VU);
+       snd_soc_update_bits(codec, WM8962_LEFT_ADC_VOLUME,
+                           WM8962_ADC_VU, WM8962_ADC_VU);
+       snd_soc_update_bits(codec, WM8962_RIGHT_ADC_VOLUME,
+                           WM8962_ADC_VU, WM8962_ADC_VU);
+       snd_soc_update_bits(codec, WM8962_LEFT_DAC_VOLUME,
+                           WM8962_DAC_VU, WM8962_DAC_VU);
+       snd_soc_update_bits(codec, WM8962_RIGHT_DAC_VOLUME,
+                           WM8962_DAC_VU, WM8962_DAC_VU);
+       snd_soc_update_bits(codec, WM8962_SPKOUTL_VOLUME,
+                           WM8962_SPKOUT_VU, WM8962_SPKOUT_VU);
+       snd_soc_update_bits(codec, WM8962_SPKOUTR_VOLUME,
+                           WM8962_SPKOUT_VU, WM8962_SPKOUT_VU);
+       snd_soc_update_bits(codec, WM8962_HPOUTL_VOLUME,
+                           WM8962_HPOUT_VU, WM8962_HPOUT_VU);
+       snd_soc_update_bits(codec, WM8962_HPOUTR_VOLUME,
+                           WM8962_HPOUT_VU, WM8962_HPOUT_VU);
 
        wm8962_add_widgets(codec);
 
index 4bbc3442703f7ceaf7b20954e45365cf88db04de..30fb48ec2799444e6c6428da2853ec2121bee53f 100644 (file)
@@ -965,7 +965,7 @@ static int wm8978_probe(struct snd_soc_codec *codec)
         * written.
         */
        for (i = 0; i < ARRAY_SIZE(update_reg); i++)
-               ((u16 *)codec->reg_cache)[update_reg[i]] |= 0x100;
+               snd_soc_update_bits(codec, update_reg[i], 0x100, 0x100);
 
        /* Reset the codec */
        ret = snd_soc_write(codec, WM8978_RESET, 0);
index d40bfc9f88058985453f11cc2f0c377c0fd20bb7..4de12203e6113508712731c1060ed4e8d39cc743 100644 (file)
@@ -551,7 +551,6 @@ static int wm9090_set_bias_level(struct snd_soc_codec *codec,
 static int wm9090_probe(struct snd_soc_codec *codec)
 {
        struct wm9090_priv *wm9090 = snd_soc_codec_get_drvdata(codec);
-       u16 *reg_cache = codec->reg_cache;
        int ret;
 
        codec->control_data = wm9090->control_data;
@@ -576,22 +575,30 @@ static int wm9090_probe(struct snd_soc_codec *codec)
        /* Configure some defaults; they will be written out when we
         * bring the bias up.
         */
-       reg_cache[WM9090_IN1_LINE_INPUT_A_VOLUME] |= WM9090_IN1_VU
-               | WM9090_IN1A_ZC;
-       reg_cache[WM9090_IN1_LINE_INPUT_B_VOLUME] |= WM9090_IN1_VU
-               | WM9090_IN1B_ZC;
-       reg_cache[WM9090_IN2_LINE_INPUT_A_VOLUME] |= WM9090_IN2_VU
-               | WM9090_IN2A_ZC;
-       reg_cache[WM9090_IN2_LINE_INPUT_B_VOLUME] |= WM9090_IN2_VU
-               | WM9090_IN2B_ZC;
-       reg_cache[WM9090_SPEAKER_VOLUME_LEFT] |=
-               WM9090_SPKOUT_VU | WM9090_SPKOUTL_ZC;
-       reg_cache[WM9090_LEFT_OUTPUT_VOLUME] |=
-               WM9090_HPOUT1_VU | WM9090_HPOUT1L_ZC;
-       reg_cache[WM9090_RIGHT_OUTPUT_VOLUME] |=
-               WM9090_HPOUT1_VU | WM9090_HPOUT1R_ZC;
-
-       reg_cache[WM9090_CLOCKING_1] |= WM9090_TOCLK_ENA;
+       snd_soc_update_bits(codec, WM9090_IN1_LINE_INPUT_A_VOLUME,
+                           WM9090_IN1_VU | WM9090_IN1A_ZC,
+                           WM9090_IN1_VU | WM9090_IN1A_ZC);
+       snd_soc_update_bits(codec, WM9090_IN1_LINE_INPUT_B_VOLUME,
+                           WM9090_IN1_VU | WM9090_IN1B_ZC,
+                           WM9090_IN1_VU | WM9090_IN1B_ZC);
+       snd_soc_update_bits(codec, WM9090_IN2_LINE_INPUT_A_VOLUME,
+                           WM9090_IN2_VU | WM9090_IN2A_ZC,
+                           WM9090_IN2_VU | WM9090_IN2A_ZC);
+       snd_soc_update_bits(codec, WM9090_IN2_LINE_INPUT_B_VOLUME,
+                           WM9090_IN2_VU | WM9090_IN2B_ZC,
+                           WM9090_IN2_VU | WM9090_IN2B_ZC);
+       snd_soc_update_bits(codec, WM9090_SPEAKER_VOLUME_LEFT,
+                           WM9090_SPKOUT_VU | WM9090_SPKOUTL_ZC,
+                           WM9090_SPKOUT_VU | WM9090_SPKOUTL_ZC);
+       snd_soc_update_bits(codec, WM9090_LEFT_OUTPUT_VOLUME,
+                           WM9090_HPOUT1_VU | WM9090_HPOUT1L_ZC,
+                           WM9090_HPOUT1_VU | WM9090_HPOUT1L_ZC);
+       snd_soc_update_bits(codec, WM9090_RIGHT_OUTPUT_VOLUME,
+                           WM9090_HPOUT1_VU | WM9090_HPOUT1R_ZC,
+                           WM9090_HPOUT1_VU | WM9090_HPOUT1R_ZC);
+
+       snd_soc_update_bits(codec, WM9090_CLOCKING_1,
+                           WM9090_TOCLK_ENA, WM9090_TOCLK_ENA);
 
        wm9090_set_bias_level(codec, SND_SOC_BIAS_STANDBY);